Android release APK crash with java.lang.AssertionError: impossible in java.lang.Enum

后端 未结 2 764
误落风尘
误落风尘 2020-12-09 01:37

I\'ve just built an APK using Gradle for release (ProGuard 4.9 and signed). When I launch the app it crash on this error :

E/AndroidRuntime( 8662): java.lan         


        
相关标签:
2条回答
  • 2020-12-09 02:29

    You have to tell ProGuard to keep some enum methods.

    The Android SDK tools use this ProGuard configuration to achieve it:

    # For enumeration classes, see http://proguard.sourceforge.net/manual/examples.html#enumerations
    -keepclassmembers enum * {
        public static **[] values();
        public static ** valueOf(java.lang.String);
    }
    

    You can either add the above rule to your ProGuard configuration or you can (what I'd prefer) include the default Android rules:

    minifyEnabled true
    proguardFile getDefaultProguardFile('proguard-android.txt')
    proguardFile file('./proguard-project.txt')
    
    0 讨论(0)
  • 2020-12-09 02:40

    Log of my error

    E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.zonaprop.android, PID: 20337
    java.lang.AssertionError: Missing field in 
    ...
    Caused by: java.lang.NoSuchFieldException: 
        at java.lang.Class.getField
    

    The follow answer worked for me https://stackoverflow.com/a/30167048/5279996

    0 讨论(0)
提交回复
热议问题