Getting java.lang ExceptionInInitializerError when initializing ACRA

3.8k views Asked by At

I integrated ACRA to my application to get crash reports from my app in beta stadium so I'm able to fix bugs, find errors in code, etc. If I run this on the emulator everything works fine and ACRA is up and running, but if I export a signed package of my application with Android Tools I get an ExceptionInInitializeError and the application is force closed on the device. If I catch this Error and proceed without ACRA the app itself runs like a charm...

has anybody here got the same issue with ACRA? could it be that it has something to do with ProGuard? I followed the ProGuard how to on ACRA homepage but perhaps I'm missing something on this?

here's what my proguard.cfg looks like: -injars 'C:\Workspaces\motodevWs\gp2012\bin\classes' -injars 'C:\Workspaces\motodevWs\gp2012\libs' -outjars 'C:\Workspaces\motodevWs\gp2012\bin\classes-processed.jar'

-libraryjars 'C:\android\android-sdk\platforms\android-7\android.jar'
-libraryjars 'C:\android\android-sdk\add-ons\addon_google_apis_google_inc_7    \libs\maps.jar'

-optimizations !code/simplification/arithmetic
-allowaccessmodification
-repackageclasses ''
-keepattributes *Annotation*,SourceFile,LineNumberTable,*Annotation*
-renamesourcefileattribute SourceFile
-dontpreverify
-dontwarn java.awt.**,javax.security.**,java.beans.**,com.sun.**


-keep public class * extends android.app.Activity

-keep public class * extends android.app.Application

-keep public class * extends android.app.Service

-keep public class * extends android.content.BroadcastReceiver

-keep public class * extends android.content.ContentProvider

-keep public class * extends android.view.View {
    public <init>(android.content.Context);
    public <init>(android.content.Context,android.util.AttributeSet);
    public <init>(android.content.Context,android.util.AttributeSet,int);
    public void set*(...);
}

-keepclasseswithmembers class * {
    public <init>(android.content.Context,android.util.AttributeSet);
}

-keepclasseswithmembers class * {
    public <init>(android.content.Context,android.util.AttributeSet,int);
}

-keepclassmembers class * extends android.os.Parcelable {
    static android.os.Parcelable$Creator CREATOR;
}

-keepclassmembers class **.R$* {
    public static <fields>;
}

# keep this class so that logging will show 'ACRA' and not a obfuscated name like 'a'.
# Note: if you are removing log messages elsewhere in this file then this isn't necessary
-keep class org.acra.ACRA {
    <fields>;
    <methods>;
}

# keep this around for some enums that ACRA needs
-keep class org.acra.ReportingInteractionMode {
    <fields>;
    <methods>;
}

# keep this otherwise it is removed by ProGuard
-keep public class org.acra.ErrorReporter {
    public void addCustomData(java.lang.String,java.lang.String);
}

# keep this otherwise it is removed by ProGuard
-keep public class org.acra.ErrorReporter {
    public org.acra.ErrorReporter$ReportsSenderWorker handleSilentException(java.lang.Throwable);
}

PROBLEM SOLVED! After some effort on research and rethinking my problem I found the solution to the problem and it was indeed in my proguard.cfg file where I missed something!

somehow I managed not to keep enums, now I added

-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}

to my proguard.cfg and everything is working perfectly!!

2

There are 2 answers

0
herom On BEST ANSWER

So, to close this question with the answer I found myself, here is what I did to resolve this particular problem :) (taken from my question post):

After some effort on research and rethinking my problem I found the solution to the problem and it was indeed in my proguard.cfg file where I missed something!

somehow I managed not to keep enums, now I added

-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}

to my proguard.cfg and everything is working perfectly!!

0
MikeWallaceDev On

THere is now a wiki concerning using ACRA with ProGuard

https://github.com/ACRA/acra/wiki/Proguard