我试图修复一个程序规则,但直到现在还没有成功。
我的项目使用5个libs,包装起始相等(com.mylibs.one,com.mylibs.two,...)
我不知道这是不是问题,但当我在proguard-rules.pro
中编写规则时,我只指定一次com.libs
。
当我运行我的应用时,我只得到java.lang.NoClassDefFoundError
。
我的proguard-rules.pro
-optimizationpasses 5
-dontusemixedcaseclassnames
-dontshrink
-dontskipnonpubliclibraryclasses
-dontskipnonpubliclibraryclassmembers
-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.google.vending.licensing.ILicensingService
-keep public class com.android.vending.licensing.ILicensingService
-keep public class * extends android.support.v4.app.Fragment
-keep public class * extends android.app.Fragment
-keep class com.j256.**
-keep public class android.database.sqlite.**
-keep class javax.** { *; }
-keep class org.** { *; }
-keep class twitter4j.** { *; }
-keep class com.samsung.** {*;}
-keep class org.xmlpull.** { *; }
-keep class org.apache.** { *; }
-keep class com.mylibs.** { *; }
-keep interface com.mylibs.** { *; }
-keep enum com.mylibs.** { *; }
-keep class com.mopub.** { *; }
-keep class android.support.** { *; }
-keep class org.webrtc.** { *; }
-keep class com.google.zxing.** { *; }
-keep class com.facebook.** {*;}
-keepclassmembers class com.j256.** { *;}
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet);
}
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet, int);
}
-keepclasseswithmembernames class * {
native <methods>;
}
-keepclassmembers class * extends android.app.Activity {
public void *(android.view.View);
}
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
-keepclassmembers class * {
public void *(android.view.View);
}
-keepclassmembers class * extends android.app.Activity {
public void *(android.view.View);
}
-keepclasseswithmembers class * extends android.app.Activity {
public <init>(android.content.Context);
}
-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}
-keepclassmembers class * extends android.content.Context {
public void get*(...);
public void set*(...);
public void on*(...);
}
-keepclassmembers class * implements android.os.Parcelable {
static android.os.Parcelable$Creator CREATOR;
}
-keepclassmembers class com.mylibs {
public *;
}
-dontwarn com.samsung.**
-dontwarn org.apache.**
-dontwarn org.xmlpull.v1.**
-dontwarn com.mylibs.**
-dontwarn android.net.http.AndroidHttpClient
-dontwarn com.google.android.gms.**
-dontwarn android.support.**
-dontwarn org.webrtc.**
-dontwarn com.google.zxing.**
-dontnote org.xmlpull.v1.**
-dontnote org.apache.**
-assumenosideeffects class android.util.Log {
public static *** d(...);
public static *** v(...);
}
错误:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.myproject, PID: 10213
java.lang.NoClassDefFoundError: Failed resolution of: Lw;
at com.mylibs.blabla.<init>(Unknown Source)
at com.mylibs.blabla.build(Unknown Source)
at com.mylibs.blabla.build(Unknown Source)
at com.myproject.bla.<init>(Unknown Source)
at com.myproject.build(Unknown Source)
at com.myproject.application.onCreate(Unknown Source)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1013)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4707)
at android.app.ActivityThread.-wrap1(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1405)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: java.lang.ClassNotFoundException: Didn't find class "w" on path: DexPathList[[zip file "/data/app/com.myproject-2/base.apk"],nativeLibraryDirectories=[/data/app/com.myproject-2/lib/x86, /data/app/com.myproject-2/base.apk!/lib/x86, /vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at com.mylibs.Config.<init>(Unknown Source)
at com.mylibs.Config.build(Unknown Source)
at com.mylibs.Config.build(Unknown Source)
at com.myproject.Manager.<init>(Unknown Source)
at com.myproject.Manager.build(Unknown Source)
at com.myproject.Application.onCreate(Unknown Source)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1013)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4707)
at android.app.ActivityThread.-wrap1(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1405)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Suppressed: java.lang.ClassNotFoundException: w
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 17 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available
寻求帮助!