gpt4 book ai didi

java - Android ProGuard "java.lang.nosuchfielderror: Toast"异常

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:11:20 25 4
gpt4 key购买 nike

我用 ProGuard 混淆了我的 Android 应用程序,当我尝试运行混淆后的 .apk 时,它抛出:

java.lang.nosuchfielderror: Toast

这是我的 proguard.cfg 文件:

<!-- language: lang-none -->

-injars bin/classes //injars
-injars libs //injars
-outjars bin/classes-processed.jar
-optimizationpasses 1
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-verbose
-allowaccessmodification
-keepattributes *Annotation*
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
-printmapping D:/out.map
-renamesourcefileattribute ProGuard
-keepattributes Exceptions,InnerClasses,Signature,Deprecated,
SourceFile,LineNumberTable,*Annotation*,EnclosingMethod
-libraryjars C:/Program Files/Android/android-sdk/platforms/android
12/android.jar
-dontwarn android.support.**
-dontwarn com.android.**
-dontwarn com.google.**
-dontwarn org.apache.**
-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.app.backup.BackupAgentHelper
-keep public class * extends android.preference.Preference
-keep public class com.android.vending.licensing.ILicensingService
-keepclasseswithmembernames class * {
native <methods>;
}

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

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

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

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

-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}

-keepclassmembers class * extends android.app.Activity {
public void *On*Click(android.view.View);
public void *on*Click(android.view.View);
}

-keepclassmembers class * implements java.io.Serializable {
static final long serialVersionUID;
private static final java.io.ObjectStreamField[] serialPersistentFields;
private void writeObject(java.io.ObjectOutputStream);
private void readObject(java.io.ObjectInputStream);
java.lang.Object writeReplace();
java.lang.Object readResolve();
}

最佳答案

看来您正在使用 ACRA 进行错误报告。我遇到了同样的问题,在这里找到了答案:http://code.google.com/p/acra/issues/detail?id=22

解决方法是添加

-keep class org.acra.ReportingInteractionMode { *; }

到你的proguard配置文件

关于java - Android ProGuard "java.lang.nosuchfielderror: Toast"异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10026491/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com