我在我的应用上运行了proguard工具来混淆代码。我知道当混淆发生时,proguard会根据自己的判断来缩小和优化应用程序。因此,在混淆应用程序后,应用程序正确打开,但当我尝试登录时,它会崩溃。这是我连接设备时获得的最佳日志。
10-03 11:12:47.384: E/AndroidRuntime(15058): FATAL EXCEPTION: AsyncTask #1
10-03 11:12:47.384: E/AndroidRuntime(15058): java.lang.RuntimeException: An error occured while executing doInBackground()
10-03 11:12:47.384: E/AndroidRuntime(15058): at android.os.AsyncTask$3.done(AsyncTask.java:299)
10-03 11:12:47.384: E/AndroidRuntime(15058): at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:352)
10-03 11:12:47.384: E/AndroidRuntime(15058): at java.util.concurrent.FutureTask.setException(FutureTask.java:219)
10-03 11:12:47.384: E/AndroidRuntime(15058): at java.util.concurrent.FutureTask.run(FutureTask.java:239)
10-03 11:12:47.384: E/AndroidRuntime(15058): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
10-03 11:12:47.384: E/AndroidRuntime(15058): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
10-03 11:12:47.384: E/AndroidRuntime(15058): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
10-03 11:12:47.384: E/AndroidRuntime(15058): at java.lang.Thread.run(Thread.java:856)
10-03 11:12:47.384: E/AndroidRuntime(15058): Caused by: java.lang.ExceptionInInitializerError
10-03 11:12:47.384: E/AndroidRuntime(15058): at com.winwin.a.d.c.doInBackground(Unknown Source)
10-03 11:12:47.384: E/AndroidRuntime(15058): at com.winwin.a.d.c.doInBackground(Unknown Source)
10-03 11:12:47.384: E/AndroidRuntime(15058): at android.os.AsyncTask$2.call(AsyncTask.java:287)
10-03 11:12:47.384: E/AndroidRuntime(15058): at java.util.concurrent.FutureTask.run(FutureTask.java:234)
10-03 11:12:47.384: E/AndroidRuntime(15058): ... 4 more
10-03 11:12:47.384: E/AndroidRuntime(15058): Caused by: java.lang.ExceptionInInitializerError
10-03 11:12:47.384: E/AndroidRuntime(15058): at com.winwin.a.c.d.<clinit>(Unknown Source)
10-03 11:12:47.384: E/AndroidRuntime(15058): ... 8 more
10-03 11:12:47.384: E/AndroidRuntime(15058): Caused by: java.lang.ExceptionInInitializerError
10-03 11:12:47.384: E/AndroidRuntime(15058): at com.b.a.c.ad.<clinit>(Unknown Source)
10-03 11:12:47.384: E/AndroidRuntime(15058): ... 9 more
10-03 11:12:47.384: E/AndroidRuntime(15058): Caused by: java.lang.NoSuchFieldError: ANY
10-03 11:12:47.384: E/AndroidRuntime(15058): at java.lang.Class.getDeclaredAnnotation(Native Method)
10-03 11:12:47.384: E/AndroidRuntime(15058): at java.lang.Class.getAnnotation(Class.java:260)
10-03 11:12:47.384: E/AndroidRuntime(15058): at com.b.a.c.f.ag.<clinit>(Unknown Source)
我曾认为这是因为Proguard删除了它认为不必要的某些类或方法,从而导致崩溃。我所做的是再次运行Proguard,这次包括
-dontobfuscate
我希望这个工具能够缩小和优化,但不要混淆,这样我就可以得到一个正确的读数,知道缺少了什么。然而,当我使用这个工具生成apk时,这次运行得非常完美。问题是它没有被混淆。
所以我现在不知道该怎么办了。
有人有什么想法吗?
*编辑*
这是我的配置文件
To enable ProGuard in your project, edit project.properties
to define the proguard.config property as described in that file.
Add project specific ProGuard rules here.
By default, the flags in this file are appended to flags specified
in ${sdk.dir}/tools/proguard/proguard-android.txt
You can edit the include path and order by changing the ProGuard
include property in project.properties.
For more details, see
http://developer.android.com/guide/developing/tools/proguard.html
Add any project specific keep options here:
-libraryjars libs/crashlytics.jar
-keep class com.facebook.** {
*;
}
-keepattributes Signature
-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-verbose
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
-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 all classes that might be used in XML layouts
-keep public class * extends android.view.View
-keep public class * extends android.app.Fragment
-keep public class * extends android.support.v4.Fragment
-keepattributes *Annotation*, EnclosingMethod
-keep class com.winwin.** { *; }
-keepnames class org.codehaus.jackson.** { *; }
-dontoptimize
-dontshrink
keep all public and protected methods that could be used by java reflection
-keepclassmembernames class * {
public protected <methods>;
}
-keepclasseswithmembernames class * {
native <methods>;
}
-keepclasseswithmembernames class * {
public <init>(android.content.Context, android.util.AttributeSet);
}
-keepclasseswithmembernames class * {
public <init>(android.content.Context, android.util.AttributeSet, int);
}
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}
-dontwarn **CompatHoneycomb
-dontwarn org.htmlcleaner.*
-dontwarn com.fasterxml.jackson.databind.ext.**
If your project uses WebView with JS, uncomment the following
and specify the fully qualified class name to the JavaScript interface
class:
-keepclassmembers class fqcn.of.javascript.interface.for.webview {
public *;
}
==========================
这是我的项目资源管理器面板。
android-support-v7-appcompat / ConverserSdk / facebook / google-play-services_lib / library / Main / MainWs / SlidingMenu
因此,我的主要内容依赖于其他每个包。
-keep class reflection.using.package.name.** { *; }
。 - GrIsHureflection.using.package.name
替换为库的包名称。例如,如果是Jackson,则为org.codehaus
。(这可能会保留太多未混淆的内容,但可以给您一个更安全的起点。) - laalto