目前我在发布模式下登录后启动时遇到应用程序崩溃的问题,但是在调试模式下它工作正常。
我现在无法弄清楚问题,即使我做了研究并一直在寻找解决方案,但我仍然没有设法让它工作
当应用程序崩溃时,它不会显示在我的应用程序日志中,而是显示在"无过滤器"中
错误是
java.lang.NoSuchFieldError: NO_ACTION
at java.lang.reflect.Method.getDefaultValue(Native Method)
at java.lang.reflect.Method.getDefaultValue(Method.java:353)
at libcore.reflect.AnnotationFactory.getElementsDescription(AnnotationFactory.java:75)
at libcore.reflect.AnnotationFactory.<init>(AnnotationFactory.java:112)
at libcore.reflect.AnnotationFactory.createAnnotation(AnnotationFactory.java:94)
at java.lang.reflect.Field.getAnnotation(Native Method)
at java.lang.reflect.Field.getAnnotation(Field.java:209)
at com.a.g.a(Unknown Source)
at com.a.b.a(Unknown Source)
at com.a.b.a(Unknown Source)
at com.a.b.onCreate(Unknown Source)
at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:252)
at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:164)
at com.a.h.c(Unknown Source)
at com.a.h.a(Unknown Source)
at com.a.a.a(Unknown Source)
at com.socialproperty.app.service.AppController.onCreate(Unknown Source)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1007)
at com.lbe.security.service.core.client.b.x.callApplicationOnCreate(Unknown Source)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4361)
at android.app.ActivityThread.access$1500(ActivityThread.java:138)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1259)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5034)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:805)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:621)
at dalvik.system.NativeStart.main(Native Method)
格拉德尔配置
apply plugin: 'android'
android {
signingConfigs {
config {
keyAlias 'keyalias'
keyPassword 'xxxxxxxxx'
storeFile file('path to keystore')
storePassword 'xxxxxxx'
}
}
compileSdkVersion 19
buildToolsVersion '19.1.0'
defaultConfig {
minSdkVersion 14
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled true
signingConfig signingConfigs.config
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.android.gms:play-services:6.1.+'
compile 'com.android.support:appcompat-v7:20.+'
compile 'com.android.support:support-v13:21.0.0'
compile 'com.android.support:support-v4:21.0.0'
compile 'com.squareup.retrofit:retrofit:1.8.0'
compile 'com.squareup.picasso:picasso:2.4.0'
compile 'com.squareup.okio:okio:1.0.1'
compile 'com.squareup.okhttp:okhttp:2.1.0'
compile 'com.squareup.okhttp:okhttp-urlconnection:2.1.0'
}
专业卫士
-dontwarn retrofit.**
-dontwarn okio.**
-dontwarn com.squareup.okhttp.**
你的问题是 proguard 正在重命名你的代码,而你正在使用反射。
最简单的解决方法是禁用 proguard(在 build.gradle
文件中将 minifyEnabled
设置为 false)。
如果要使 proguard 保持启用状态,则需要在 proguard 规则文件中添加-keep yourclass
。如果我想保留 Activity
类的示例:
-keep class android.app.Activity
如果我想保留所有android.app
包:
-keep class android.app.**
有关 proguard 的更多信息,请点击此处。