我已经实施了ProGuard来切断不必要的代码。但在应用程序启动后,我收到以下错误 -
java.lang.NoClassDefFoundError: Failed resolution of: Ljavax/naming/ldap/LdapName;
at b.a.b.e.d.a.b(Unknown Source)
at b.a.b.e.d.a.a(Unknown Source)
at b.a.b.e.d.a.a(Unknown Source)
at b.a.b.e.d.a.a(Unknown Source)
at b.a.b.e.d.f.a(Unknown Source)
at b.a.b.e.d.f.a(Unknown Source)
at b.a.b.e.d.f.a(Unknown Source)
at b.a.b.h.c.h.a(Unknown Source)
at b.a.b.h.c.p.a(Unknown Source)
at b.a.b.h.b.o.a(Unknown Source)
at b.a.b.h.b.o.a(Unknown Source)
at b.a.b.h.b.a.a(Unknown Source)
at b.a.b.h.b.h.a(Unknown Source)
at b.a.b.h.b.h.a(Unknown Source)
at b.a.b.h.b.h.execute(Unknown Source)
at com.c.a.ae.a(Unknown Source)
at com.c.a.b.a(Unknown Source)
at com.c.a.aa.run(Unknown Source)
at java.lang.Thread.run(Thread.java:818)
Caused by: java.lang.ClassNotFoundException: Didn't find class "javax.naming.ldap.LdapName" on path: DexPathList[[zip file "/data/app/bd.com.chalo-1/base.apk"],nativeLibraryDirectories=[/data/app/bd.com.chalo-1/lib/arm64, /data/app/bd.com.chalo-1/base.apk!/lib/arm64-v8a, /vendor/lib64, /system/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
... 19 more
Suppressed: java.lang.ClassNotFoundException: javax.naming.ldap.LdapName
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)
... 20 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available
我现在该怎么办?这与我的图书馆有关吗?
答案 0 :(得分:0)
Android的ProGuard文档描述如下:
“ProGuard工具通过删除未使用的代码并使用语义模糊的名称重命名类,字段和方法来缩小,优化和混淆代码。结果是一个较小的.apk文件,更难以进行逆向工程.... ProGuard运行是完全可选的,但强烈推荐。“
如果您的应用包含第三方库,广播接收器,自定义小部件等,添加proguard会导致问题。因此您需要添加proguard规则以在运行时添加此类,否则类将无法在APK版本中编译,您将得到错误
有关proguard及其用法的详细信息,请参阅以下链接:http://omgitsmgp.com/2013/09/09/a-conservative-guide-to-proguard-for-android/
您可以使用标准的proguard规则表单:
# Add any project specific keep options here:
# 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 *;
#}
# Obfuscation parameters:
#-dontobfuscate
-useuniqueclassmembernames
-keepattributes SourceFile,LineNumberTable
-allowaccessmodification
# Ignore warnings:
#-dontwarn org.mockito.**
#-dontwarn org.junit.**
#-dontwarn com.robotium.**
#-dontwarn org.joda.convert.**
# Ignore warnings: We are not using DOM model
-dontwarn com.fasterxml.jackson.databind.ext.DOMSerializer
# Ignore warnings: https://github.com/square/okhttp/wiki/FAQs
-dontwarn com.squareup.okhttp.internal.huc.**
# Ignore warnings: https://github.com/square/okio/issues/60
-dontwarn okio.**
# Ignore warnings: https://github.com/square/retrofit/issues/435
-dontwarn com.google.appengine.api.urlfetch.**
# Keep the pojos used by GSON or Jackson
-keep class com.futurice.project.models.pojo.* { ; }
# Keep GSON stuff
-keep class sun.misc.Unsafe { *; }
-keep class com.google.gson.* { ; }
-keep public class Socket
# Keep Jackson stuff
-keep class org.codehaus.* { ; }
-keep class com.fasterxml.jackson.annotation.* { ; }
# Keep these for GSON and Jackson
-keepattributes Signature
-keepattributes Annotation
-keepattributes EnclosingMethod
# Keep Retrofit
-keep class retrofit.* { ; }
-keepclasseswithmembers class * {
@retrofit.** *;
}
-keepclassmembers class * {
@retrofit.** *;
}
-keep public class com.mikhaellopez:circularimageview:2.1.1.* { ; }
# Keep Picasso
-keep class com.squareup.picasso.* { ; }
-keepclasseswithmembers class * {
@com.squareup.picasso.** *;
}
-keepclassmembers class * {
@com.squareup.picasso.** *;
}
在您的proguard文件中添加此规则... 有关标准表单的详细信息,请参阅:https://github.com/futurice/android-best-practices/blob/master/templates/rx-architecture/app/proguard-rules.pro