2

我的项目在没有 Proguard 的情况下运行良好,即在我运行项目时安装由 Eclipse 生成的 apk 并将其安装在三星 Galaxy 设备上,一切都很好。但是,当我尝试使用 Proguard 导出已签名的 apk 时,可以正常导出,但是当我尝试运行应用程序时,该应用程序不起作用。我在模拟器上安装了 apk 以查看 Logcat 的异常,它返回给我的是这样的:

11-28 02:28:33.709: E/AndroidRuntime(853): FATAL EXCEPTION: main
11-28 02:28:33.709: E/AndroidRuntime(853): java.lang.ExceptionInInitializerError
11-28 02:28:33.709: E/AndroidRuntime(853):  at    com.actionbarsherlock.app.SherlockActivity.c(Unknown Source)
11-28 02:28:33.709: E/AndroidRuntime(853):  at com.actionbarsherlock.app.SherlockActivity.setContentView(Unknown Source)
11-28 02:28:33.709: E/AndroidRuntime(853):  at com.linxter.allaware.views.AllAwareActivity.a(Unknown Source)
11-28 02:28:33.709: E/AndroidRuntime(853):  at   com.linxter.allaware.views.StartupActivity.onCreate(Unknown Source)
11-28 02:28:33.709: E/AndroidRuntime(853):  at android.app.Activity.performCreate(Activity.java:4465)
11-28 02:28:33.709: E/AndroidRuntime(853):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
11-28 02:28:33.709: E/AndroidRuntime(853):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
11-28 02:28:33.709: E/AndroidRuntime(853):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
11-28 02:28:33.709: E/AndroidRuntime(853):  at android.app.ActivityThread.access$600(ActivityThread.java:123)
11-28 02:28:33.709: E/AndroidRuntime(853):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
11-28 02:28:33.709: E/AndroidRuntime(853):  at android.os.Handler.dispatchMessage(Handler.java:99)
11-28 02:28:33.709: E/AndroidRuntime(853):  at android.os.Looper.loop(Looper.java:137)
11-28 02:28:33.709: E/AndroidRuntime(853):  at android.app.ActivityThread.main(ActivityThread.java:4424)
11-28 02:28:33.709: E/AndroidRuntime(853):  at java.lang.reflect.Method.invokeNative(Native Method)
11-28 02:28:33.709: E/AndroidRuntime(853):  at java.lang.reflect.Method.invoke(Method.java:511)
11-28 02:28:33.709: E/AndroidRuntime(853):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
11-28 02:28:33.709: E/AndroidRuntime(853):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
11-28 02:28:33.709: E/AndroidRuntime(853):  at dalvik.system.NativeStart.main(Native Method)
11-28 02:28:33.709: E/AndroidRuntime(853): Caused by: java.lang.IllegalArgumentException: Class a is not annotated with @Implementation
11-28 02:28:33.709: E/AndroidRuntime(853):  at com.actionbarsherlock.a.a(Unknown Source)
11-28 02:28:33.709: E/AndroidRuntime(853):  at com.actionbarsherlock.a.<clinit>(Unknown Source)
11-28 02:28:33.709: E/AndroidRuntime(853):  ... 18 more

我使用最新版本的 Proguard,4.8 版和最新版本的 ActionBarSherlock,4.2.0。这是我的 Proguard 配置文件的一部分:

-ignorewarnings
-target 1.6
-optimizationpasses 5
-printmapping mapping.txt
# -overloadaggressively
-dontskipnonpubliclibraryclasses
-dontpreverify
-verbose
-dump class_files.txt
-printseeds seeds.txt
-printusage unused.txt

# The -optimizations option disables some arithmetic simplifications that Dalvik 1.0 and 1.5 can't handle.
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*

# Recommended configuration for ActionBarSherlock on http://actionbarsherlock.com/faq.html
-keep class android.support.v4.app.** { *; }
-keep interface android.support.v4.app.** { *; }
-keep class com.actionbarsherlock.** { *; }
-keep interface com.actionbarsherlock.** { *; }
-keepattributes *Annotation*

# Keep classes which are entry points.
-keep public class * extends android.app.Activity
-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.Application


-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*(...);
}

# Also keep - Enumerations. Keep the special static methods that are required in
# enumeration classes.
-keepclassmembers enum  * {
    public static **[] values();
    public static ** valueOf(java.lang.String);
}

# Keep names - Native method names. Keep all native class/method names.
-keepclasseswithmembers,allowshrinking class * {
    native <methods>;
}

怎么了?我很感激任何帮助。谢谢你。

4

0 回答 0