minifyEnabled true leads to crash on app start

半城伤御伤魂 提交于 2020-07-18 11:43:39

问题


Unfortunately XX has stopped.

I receive this message as soon as I start my productive app, when I set

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

I do not have any additional proguard-rules (cause no library stated that it is necessary).

My dependencies look like this:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.loopj.android:android-async-http:1.4.9'
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.android.support:design:23.1.1'
    compile 'com.google.android.gms:play-services-gcm:8.4.0'
    compile 'com.google.android.gms:play-services-ads:8.4.0'
    compile 'me.leolin:ShortcutBadger:1.1.4@aar'
    compile 'com.facebook.android:facebook-android-sdk:4.+'
    compile 'com.jraska:falcon:1.0.0'
}

What I tried was to add

-keep class com.loopj.** {*;}
-keep class com.jraska.** {*;}
-keep class me.leolin.** {*;}
-keep class com.android.** {*;}
-keep class com.google.** {*;}
-keep class com.facebook.** {*;}

to my proguard-rules, but still the same error. Any idea?


回答1:


So I found the error in the log

W/SupportMenuInflater(29041): Cannot instantiate class: android.support.v7.widget.SearchView
W/SupportMenuInflater(29041): java.lang.NoSuchMethodException: <init> [class android.content.Context]

After adding

-keep class android.support.v7.widget.SearchView { *; }

to my proguard-rules file, everything worked as expected.



来源:https://stackoverflow.com/questions/36249005/minifyenabled-true-leads-to-crash-on-app-start

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