初始化 ACRA 时出现 java.lang ExceptionInInitializerError

发布于 2025-01-02 19:52:30 字数 3047 浏览 3 评论 0原文

我将 ACRA 集成到我的应用程序中,以便从 beta 体育场中的应用程序获取崩溃报告,这样我就能够修复错误、查找代码中的错误等。如果我在模拟器上运行此程序,则一切正常并且 ACRA 已启动并运行,但是如果我使用 Android Tools 导出应用程序的签名包,我会收到 ExceptionInInitializeError 并且应用程序在设备上被强制关闭。如果我发现这个错误并在没有 ACRA 的情况下继续,应用程序本身就会像魅力一样运行......

这里有人遇到与 ACRA 相同的问题吗?难道和ProGuard有关系?我按照 ACRA 主页上的 ProGuard 操作方法进行操作,但也许我遗漏了一些内容?

这是我的 proguard.cfg 的样子: -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);
}

问题已解决! 经过一番研究和重新思考我的问题后,我找到了问题的解决方案,它确实在我的 proguard.cfg 文件中,我错过了一些东西!

不知何故,我设法不保留枚举,现在我添加

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

到我的 proguard.cfg 中,一切都运行良好!

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

二手情话 2025-01-09 19:52:30

因此,用我自己找到的答案来结束这个问题,这是我为解决这个特定问题所做的:)(取自我的问题帖子):

经过一番研究和重新思考我的问题后,我找到了问题的解决方案,并且确实是在我的 proguard.cfg 文件中我错过了一些东西!

不知怎的,我设法不保留枚举,现在我添加

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

到我的 proguard.cfg 中,一切都工作正常!

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

微暖i 2025-01-09 19:52:30

现在有一个关于使用 ACRA 和 ProGuard 的 wiki

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

THere is now a wiki concerning using ACRA with ProGuard

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文