我在eclipse上导出应用程序时使用了proguard,logcat没有显示错误,但是当我运行应用程序时出现以下错误。
java.lang.NullPointerException
at hn.<init>(Unknown Source)
at hp.<init>(Unknown Source)
at hc.a(Unknown Source)
at hc.<init>(Unknown Source)
at hb.<init>(Unknown Source)
at hb.<init>(Unknown Source)
at com.example.musicplayer.SongManager.c(Unknown Source)
at com.example.musicplayer.SongManager.b(Unknown Source)
at com.example.musicplayer.SongManager.e(Unknown Source)
at jr.onClick(Unknown Source)
at android.view.View.performClick(View.java:4247)
at android.view.View$PerformClick.run(View.java:17728)
etc ...
我使用了followin proguard配置(在stackoverflow上发现它不记得在哪里):
-injars bin/classes
-injars libs
-outjars bin/classes-processed.jar
-libraryjars C:/eclipse/sdk/platforms/android-19/android.jar
-dontpreverify
-repackageclasses ''
-allowaccessmodification
-optimizations !code/simplification/arithmetic
-keepattributes *Annotation*
-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.content.Context {
public void *(android.view.View);
public void *(android.view.MenuItem);
}
-keepclassmembers class **.R$* {
public static <fields>;
}
要使用它,我只是在project.properties中取消注释,这些属于proguard。我使用API 19编译器,我在Jelly Bean 4.3.1上运行app,并收到上面的错误。任何帮助表示赞赏。
编辑:问题出现在通知中,当我按下按钮时,它会激活NotificationReceiver类的意图(实现BroadcastReceiver,在清单中声明),并且错误在这些按钮上。我使用Notification.Builder创建通知,使用addAction添加这些按钮。答案 0 :(得分:1)
将此行添加到您的proguard conf文件中,这样com.example.musicplayer包下的类就不会被混淆。
-keep class com.example.musicplayer.** { *; }