0

I get this error when building for release. This happens for release only. The error doesn't appear for debuggable or when I set the flag -dontobfuscate How can I tell which classes are being stripped?

java.lang.ExceptionInInitializerError
    at androidx.fragment.app.FragmentHostCallback.<init>(SourceFile:4)
    at androidx.fragment.app.FragmentHostCallback.<init>(SourceFile:2)
    at androidx.fragment.app.FragmentActivity$HostCallbacks.<init>(SourceFile:2)
    at androidx.fragment.app.FragmentActivity.<init>(SourceFile:2)
    at androidx.appcompat.app.AppCompatActivity.<init>(SourceFile:1)
    at main.MainActivity.<init>(SourceFile:1)
 Caused by: java.lang.RuntimeException: Shaking error: Missing method in androidx.fragment.app.FragmentManager: void <clinit>()
    at androidx.fragment.app.FragmentManager.<clinit>(Unknown Source:9)
    at androidx.fragment.app.FragmentHostCallback.<init>(SourceFile:4) 
    at androidx.fragment.app.FragmentHostCallback.<init>(SourceFile:2) 
    at androidx.fragment.app.FragmentActivity$HostCallbacks.<init>(SourceFile:2) 
    at androidx.fragment.app.FragmentActivity.<init>(SourceFile:2) 
    at androidx.appcompat.app.AppCompatActivity.<init>(SourceFile:1) 
    at main.MainActivity.<init>(SourceFile:1) 

Proguard rules configuration

-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*,!code/allocation/variable
-keepattributes *Annotation*
-keepattributes RuntimeVisibleAnnotations,AnnotationDefault
-keepattributes SourceFile,LineNumberTable

-renamesourcefileattribute SourceFile

-if @kotlinx.serialization.Serializable class **
-keepclassmembers class <1> {
   static <1>$Companion Companion;
}

-if @kotlinx.serialization.Serializable class ** {
   static **$* *;
}
-keepclassmembers class <2>$<3> {
   kotlinx.serialization.KSerializer serializer(...);
}

-if @kotlinx.serialization.Serializable class ** {
   public static ** INSTANCE;
}
-keepclassmembers class <1> {
   public static <1> INSTANCE;
   kotlinx.serialization.KSerializer serializer(...);
}

-keep @kotlinx.android.parcel.Parcelize public class *
-keep @kotlinx.parcelize.Parcelize public class *

 -keep class retrofit2.** { *; }
 -keepclasseswithmembers class * {
     @retrofit2.http.* <methods>;
 }

 -keep class okhttp3.** { *; }
 -keep interface okhttp3.** { *; }

And this is my gradle file configuration

  defaultConfig {
        minSdk 24
        targetSdk 32
    }

    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }

Thanks

arshcaptano
  • 51
  • 1
  • 3
  • 3
  • Stripped classes/methods/fields can be found at `build/outputs/mapping/{flavor}Release/usage.txt`. Also check the `mapping.txt` file in the same directory, where you can find the symbols that were obfuscated. – Alex Lipov Jul 20 '22 at 13:47
  • Looks as if you are using `-addconfigurationdebugging` in your Proguard rules. That cause all methods which would otherwise be removed to be kept with a throwing body throwing the exception you are seeing. – sgjesse Aug 04 '22 at 07:23

0 Answers0