本文介绍了minifyEnabled true导致应用启动时崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
设置后,启动生产应用后,我会立即收到此消息
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).
我的依赖项如下:
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'
}
我试图添加
-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?
推荐答案
所以我在日志中发现了错误
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]
添加后
-keep class android.support.v7.widget.SearchView { *; }
到我的proguard-rules文件中,一切都按预期工作.
to my proguard-rules file, everything worked as expected.
这篇关于minifyEnabled true导致应用启动时崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!