Android appCompat issue with samsung and wiko

家住魔仙堡 提交于 2019-12-21 18:01:46

问题


currently I have a little problem with my application, everything works fine on most devices but on some samsung and wiko I get this error : java.lang.NoClassDefFoundError: android.support.v7.internal.view.menu.MenuBuilder

I saw some answers on the internet where they said to add the line below in the proguard file, in my case this doesn't work

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

My app is compound of 2 modules(so I have 2 proguard file), 1module is for the main app and the other is for a library

here is my gradle file for thr app module:

 apply plugin: 'com.android.application'

android {
compileSdkVersion 22
buildToolsVersion "21.1.2"

defaultConfig {
    applicationId "com.refresh.quickeer"
    minSdkVersion 16
    targetSdkVersion 22
    versionCode 1
    versionName "1.0"
    multiDexEnabled true
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
    debug
            {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.1.1'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.android.support:cardview-v7:22.1.0'
compile 'com.android.support:recyclerview-v7:22.+'
compile 'com.android.support:palette-v7:21.0.0'
compile 'com.xgc1986.android:parallaxpagertransformer:1.0.3'
compile project(':library')
}

Does somebody have a solution to this problem please ?

回答1:


Before encountering this issue I did not use proguard on my app. I resolved the issue by setting minifyEnabled true and using the following proguard config

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

I tested my app on appthwack before and after this fix to verify that it worked.




回答2:


I know exactly what you are talking about, here is the Google

Here is what I use to fix java.lang.NoClassDefFoundError: android.support.v7.internal.view.menu.MenuBuilder:

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

Here is everything that works for Support v4 and v7:

##################################################################################
#
# App Compat
# https://stackoverflow.com/questions/22441366/note-android-support-v4-text-icucompatics-cant-find-dynamically-referenced-cl
#
##################################################################################
-dontnote android.support.**
-dontwarn android.support.v4.**
-keep class android.support.v4.** { *; }
-keep interface android.support.v4.** { *; }
-dontwarn android.support.v7.**
# -keep class android.support.v7.** { *; }  # <-- excess notes
# -keep interface android.support.v7.** { *; }
# Allow obfuscation of android.support.v7.internal.view.menu.**
# to avoid problem on Samsung 4.2.2 devices with appcompat v21
# see https://code.google.com/p/android/issues/detail?id=78377
-keep class !android.support.v7.internal.view.menu.**,android.support.** {*;}  # <-- important

Source: Note: android.support.v4.text.ICUCompatIcs: can't find dynamically referenced class libcore.icu.ICU and https://code.google.com/p/android/issues/detail?id=78377



来源:https://stackoverflow.com/questions/29871727/android-appcompat-issue-with-samsung-and-wiko

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!