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

后端 未结 2 765
误落风尘
误落风尘 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条回答
  •  -上瘾入骨i
    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')
    

提交回复
热议问题