【问题标题】:java.lang.NoClassDefFoundError android.support.v7.view.menu.MenuBuilderjava.lang.NoClassDefFoundError android.support.v7.view.menu.MenuBuilder
【发布时间】:2016-07-08 10:33:01
【问题描述】:

我遇到了一个奇怪的问题

致命异常:java.lang.NoClassDefFoundError android.support.v7.view.menu.MenuBuilder

主要在4.2.24.4.2 设备上。当我开始在我的应用程序代码中使用 supportv7 库以利用材料设计工具栏时,它发生了。

这是我的build.gradle 依赖项:

    dependencies {
        compile fileTree(dir: 'libs', include: ['*.jar'])

        compile files('libs/sinch-android-verification-1.0.4.jar')
        compile project(':library')
        compile('com.crashlytics.sdk.android:crashlytics:2.2.2@aar') {
            transitive = true;
        }

        compile 'com.android.support:appcompat-v7:23.1.1'
        compile 'com.mixpanel.android:mixpanel-android:4.6.0'
        compile 'uk.co.chrisjenx:calligraphy:2.0.2'
        compile 'it.sephiroth.android.library.horizontallistview:hlistview:1.2.2'
        compile 'com.google.code.gson:gson:2.3.1'
        compile 'com.google.android.gms:play-services-gcm:8.4.0'
        compile 'io.branch.sdk.android:library:1.8.8'
        compile 'com.android.support:support-v4:23.3.0'
        compile 'com.squareup.okhttp3:okhttp:3.3.1'
        compile 'com.android.support:design:23.3.0'
        compile 'com.github.freshdesk:hotline-android:1.0.+'
        //compile 'com.facebook.android:facebook-android-sdk:[4,5)'
        compile 'com.google.android.gms:play-services-appindexing:8.4.0'
}

谁能帮忙。我被困住了,因为 2 天回来了。我已经检查了各种 proguard 修复,但也运气不好。请帮忙

【问题讨论】:

    标签: android material-design android-support-library android-toolbar


    【解决方案1】:

    在 Google 讨论中查看此问题。

    正如#150 from google groups所说的

    因为小心使用 -keep 类 !android.support.v7.internal.view.menu.**。有若干 其中的类是从 appcompat 的资源中引用的。

    更好的解决方案是添加以下行:

    -keep class !android.support.v7.internal.view.menu.*MenuBuilder*, android.support.v7.** { *; }
    -keep interface android.support.v7.** { *; }
    

    【讨论】:

    • @StanislavParkhomenko 它对我不起作用。已经检查过。
    • @StanislavParkhomenko 我们可以在依赖项中同时使用支持 v4 和 appcompat 吗?
    • @GauravArora 这是解决Android 4.2 设备中的问题,但它再次出现在Api 23.0 中。
    • @GauravArora 我猜是的。当我遇到这个问题时,使用 proguard 的那个 hack 也没有帮助我。
    • @Ironman 它也可以在 Techno 中使用。那么我应该使用什么版本的 appcompat 库来获得一个没有错误的 apk 呢?请建议
    【解决方案2】:

    没有什么对我有用,我花了 2 周时间才找到这个解决方案:

    将构建工具更改为:

    buildToolsVersion "23.0.3"
    

    替换

    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.android.support:support-v4:23.1.1'
    compile 'com.android.support:design:23.1.1'
    
    compile 'com.android.support:cardview-v7:23.1.1'
    compile 'com.android.support:recyclerview-v7:23.1.1'
    compile 'com.android.support:palette-v7:23.1.1'
    

    compile 'com.android.support:appcompat-v7:24.2.1'
    compile 'com.android.support:support-v4:24.2.1'
    compile 'com.android.support:design:24.2.1'
    
    compile 'com.android.support:cardview-v7:24.2.1'
    compile 'com.android.support:recyclerview-v7:24.2.1'
    compile 'com.android.support:palette-v7:24.2.1'
    

    【讨论】:

      猜你喜欢
      • 2016-01-24
      • 2015-08-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-10-01
      相关资源
      最近更新 更多