我正在用 libgdx 开发一个 android 动态壁纸,当我使用 proguard 时我遇到了一个大问题。这是我的动态壁纸启动时的错误:
08-17 13:55:50.755: E/AndroidRuntime(28276): FATAL EXCEPTION: main
08-17 13:55:50.755: E/AndroidRuntime(28276): java.lang.RuntimeException: Couldn't construct AndroidInput, this should never happen
08-17 13:55:50.755: E/AndroidRuntime(28276): at com.badlogic.gdx.backends.android.o.a(Unknown Source)
08-17 13:55:50.755: E/AndroidRuntime(28276): at com.badlogic.gdx.backends.android.q.a(Unknown Source)
08-17 13:55:50.755: E/AndroidRuntime(28276): at com.badlogic.gdx.backends.android.r.onCreate(Unknown Source)
08-17 13:55:50.755: E/AndroidRuntime(28276): at android.service.wallpaper.WallpaperService$Engine.attach(WallpaperService.java:777)
08-17 13:55:50.755: E/AndroidRuntime(28276): at android.service.wallpaper.WallpaperService$IWallpaperEngineWrapper.executeMessage(WallpaperService.java:1037)
08-17 13:55:50.755: E/AndroidRuntime(28276): at com.android.internal.os.HandlerCaller$MyHandler.handleMessage(HandlerCaller.java:40)
08-17 13:55:50.755: E/AndroidRuntime(28276): at android.os.Handler.dispatchMessage(Handler.java:99)
08-17 13:55:50.755: E/AndroidRuntime(28276): at android.os.Looper.loop(Looper.java:137)
08-17 13:55:50.755: E/AndroidRuntime(28276): at android.app.ActivityThread.main(ActivityThread.java:5227)
08-17 13:55:50.755: E/AndroidRuntime(28276): at java.lang.reflect.Method.invokeNative(Native Method)
08-17 13:55:50.755: E/AndroidRuntime(28276): at java.lang.reflect.Method.invoke(Method.java:511)
08-17 13:55:50.755: E/AndroidRuntime(28276): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:795)
08-17 13:55:50.755: E/AndroidRuntime(28276): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:562)
08-17 13:55:50.755: E/AndroidRuntime(28276): at dalvik.system.NativeStart.main(Native Method)
08-17 13:55:50.755: E/AndroidRuntime(28276): Caused by: java.lang.NoSuchMethodException: <init> [interface com.badlogic.gdx.a, class android.content.Context, class java.lang.Object, class com.badlogic.gdx.backends.android.a]
08-17 13:55:50.755: E/AndroidRuntime(28276): at java.lang.Class.getConstructorOrMethod(Class.java:460)
08-17 13:55:50.755: E/AndroidRuntime(28276): at java.lang.Class.getConstructor(Class.java:431)
08-17 13:55:50.755: E/AndroidRuntime(28276):
这是我的 proguard.cfg:
-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-verbose
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
-dontwarn java.awt.**
-dontnote java.awt.**
-dontwarn com.badlogic.gdx.jnigen.**
-dontwarn com.moribitotech.mtx.**
-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
-keep class com.bugsense.trace.models.** { *; }
-keepclassmembers class **.MraidView$JavaScriptInterface
{
*;
}-keepclassmembers class **.SmartWallActivity$AppWall$JavaScriptInterface
{
*;
}
-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 * extends android.app.Activity {
public void *(android.view.View);
}
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}
-keepclasseswithmembers class **.R$**
{
public static <fields>;
}
-keep 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);
void set*(***);
*** get*();
}
-keepclassmembers class *
{
static final % *;
static final java.lang.String *;
}
-keepattributes SetJavaScriptEnabled
-keepattributes JavascriptInterface
-keepattributes InlinedApi
-dontwarn com.bugsense.trace.models.**
-keep public class cmn.Proguard$KeepMembers
-keep public class * implements cmn.Proguard$KeepMembers
-keepclassmembers class * implements cmn.Proguard$KeepMembers {
<methods>;
}
-keepattributes *Annotation*
-dontwarn android.webkit.JavascriptInterface
谢谢您的帮助!