Android: app crashed when starting after signing in release mode

只愿长相守 提交于 2019-12-22 00:36:10

问题


Currently I am facing an issue of app crashing when starting after signing in release mode, but in debug mode it worked fine.

I could not figure out the problem right now, even though i did research and keep look for solutions but i still not managed to make it works

When the app crashed it doesn't show in my app logcat but shown in "No Filter"

The errors was

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)

Gradle Configuration

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'
}

ProGuard

-dontwarn retrofit.**
-dontwarn okio.**
-dontwarn com.squareup.okhttp.**

回答1:


Your problem is that proguard is renaming your code and that you're using reflection.

The easiest fix would be to disable proguard (set minifyEnabled to false in your build.gradlefile).

If you want to keep proguard enabled, you need to add -keep yourclass in your proguard rules file. Example if I want to keep the Activity class:

-keep class android.app.Activity

If I want to keep all the android.app package:

-keep class android.app.**

More informations on proguard here.



来源:https://stackoverflow.com/questions/27747739/android-app-crashed-when-starting-after-signing-in-release-mode

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