2012-04-05 47 views
10

我混淆我使用ProGuard Android應用程序,並試圖運行我混淆的apk它拋出時:的Android ProGuard的「java.lang.NoSuchFieldError的:麪包」的異常

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(); 
    } 
+1

您忘記您proguard.cfg文件請前加入其他downvote這個問題。 – rekire 2012-04-05 10:02:04

回答

4

看來您正在使用ACRA進行錯誤報告。我遇到同樣的問題,在這裏找到了答案:http://code.google.com/p/acra/issues/detail?id=22

的解決方案是

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

添加到您的ProGuard配置文件

+3

關於Acra網站,你可以找到完整的解釋: https://github.com/ACRA/acra/wiki/Proguard – 2013-08-19 08:30:56

+0

我試過答案的解決方案,但它沒有工作,所以我按照[link ](http://github.com/ACRA/acra/wiki/Proguard)Yoann Hercouet提供並運作。 – 2014-02-20 02:08:58

相關問題