2

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!!

Sam Hosseini
  • 813
  • 2
  • 9
  • 17
herom
  • 2,532
  • 29
  • 41
  • Why do you call `ErrorReporter.getInstance().init(this);` first? It's been a while since I've setup ACRA myself, but I only use `ACRA.init(this)` in my app and everything works fine. – THelper Feb 06 '12 at 12:20
  • I tried this due to a documented bug on code.google.com/p/acra on the issues table where someone mentioned that he used to get nearly the same error within the `ErrorReporter` class until he initialized it like this. I probably change it back because now I found the error in my code myself and it was indeed connected with my `proguard.cfg` file... – herom Feb 06 '12 at 12:34
  • Ok, please do not include the solution in your question because then your question status will remain "unanswered". If you post your solution as an answer and accept it, the question will be marked as "answered". – THelper Feb 06 '12 at 13:05
  • thanks @THelper, but it said that I have no chance to answer my own question in less than 8 hours due to the lack of points I gained since I'm a member... I try to answer it tomorrow with the solution ;) – herom Feb 06 '12 at 15:05

2 Answers2

0

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!!

herom
  • 2,532
  • 29
  • 41
0

THere is now a wiki concerning using ACRA with ProGuard

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

MikeWallaceDev
  • 1,458
  • 2
  • 14
  • 28