崩溃:java.lang.NoClassDefFoundError的:android.support.v7.appcompat.R $布局 [英] Crash: java.lang.NoClassDefFoundError: android.support.v7.appcompat.R$layout

查看:271
本文介绍了崩溃:java.lang.NoClassDefFoundError的:android.support.v7.appcompat.R $布局的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序的一些用户遇到此崩溃,这似乎可能是与三星设备。有没有其他人经历过这个问题,并找到了解决方法?

Some users of my app are experiencing this crash, it appears to possibly be related to Samsung devices. Has anyone else experienced this issue and found a solution?

java.lang.NoClassDefFoundError: android.support.v7.appcompat.R$layout
       at android.support.v7.app.ActionBarActivityDelegateBase.ensureSubDecor(ActionBarActivityDelegateBase.java:297)
       at android.support.v7.app.ActionBarActivityDelegateBase.setContentView(ActionBarActivityDelegateBase.java:225)
       at android.support.v7.app.ActionBarActivity.setContentView(ActionBarActivity.java:102)
       at com.afollestad.impression.ui.MainActivity.onCreate(MainActivity.java:160)
       at android.app.Activity.performCreate(Activity.java:5451)
       at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2359)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2453)
       at android.app.ActivityThread.access$900(ActivityThread.java:173)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
       at android.os.Handler.dispatchMessage(Handler.java:102)
       at android.os.Looper.loop(Looper.java:136)
       at android.app.ActivityThread.main(ActivityThread.java:5579)
       at java.lang.reflect.Method.invokeNative(Method.java)
       at java.lang.reflect.Method.invoke(Method.java:515)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1268)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1084)
       at dalvik.system.NativeStart.main(NativeStart.java)

行160设置了活动的内容视图。内容的看法是这样的:

Line 160 sets the Activity's content view. The content view is this:

<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.afollestad.lessen.ui.MainActivity"
    android:fitsSystemWindows="true">

    <LinearLayout
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_height="wrap_content"
            android:layout_width="match_parent"
            android:minHeight="?attr/actionBarSize"
            android:background="?colorPrimary"
            app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
            app:popupTheme="?popup_theme" />

        <FrameLayout
            android:id="@+id/content_frame"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />

    </LinearLayout>

    <FrameLayout
        android:layout_width="@dimen/navigation_drawer_width"
        android:layout_height="match_parent"
        android:fitsSystemWindows="true"
        android:layout_gravity="start">

        <fragment
            android:id="@+id/navigation_drawer"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:name="com.afollestad.impression.fragments.NavDrawerFragment"
            tools:layout="@layout/fragment_navdrawer"
            android:tag="NAV_DRAWER" />

    </FrameLayout>

</android.support.v4.widget.DrawerLayout>

该片段是一个简单的列表片段。

The fragment is a simple list fragment.

推荐答案

我用Proguard的具有以下配置固定的问题:

I fixed the issue by using Proguard with the following config:

-keep class !android.support.v7.internal.view.menu.**,** {*;}
-dontwarn
-ignorewarnings
-dontshrink

要启用Proguard的较新版本的摇篮(在Android的一室公寓):

To enable Proguard with newer versions of Gradle (in Android Studio):

android {

    ...

    buildTypes {
        debug {
            ...
        }
        release {
            ...
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

proguard-rules.pro就是在上面走的属性。

proguard-rules.pro is where the properties at the top go.

这篇关于崩溃:java.lang.NoClassDefFoundError的:android.support.v7.appcompat.R $布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆