我正在使用Proguard来混淆我的Android应用程序。我的应用程序使用的是ShareSDK库。
虽然我使用共享功能。我把NoClassDefFoundError作为标题。
我在proguard-rules.pro中添加了proguard-rules,如下所示:
-keep class cn.sharesdk.**{*;}
-keep class com.sina.**{*;}
-keep class **.R$* {*;}
-keep class **.R{*;}
-dontwarn cn.sharesdk.**
-dontwarn **.R$*
-keep class m.framework.**{*;}
-keep class com.mob.**{*;}
-dontwarn com.mob.**
我已经检查了下面有句子的mapping.txt:
com.mob.tools.utils.R -> com.mob.tools.utils.R:
float density -> density
int deviceWidth -> deviceWidth
java.lang.Object rp -> rp
void <init>() -> <init>
...
所以我认为班级com.mob.tools.utils.R
被保留了。
有谁能告诉我怎么办才能找到这个课程?
答案 0 :(得分:0)
将其添加到您的proguard.pro文件中
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet);
}
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet, int);
}
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
-keepclassmembers class * implements android.os.Parcelable {
static ** CREATOR;
}
-keepclassmembers class **.R$* {
public static <fields>;
}
-keepclassmembers class * {
@android.webkit.JavascriptInterface <methods>;
}
-keepclassmembers class * implements java.io.Serializable {
static final long serialVersionUID;
private static final java.io.ObjectStreamField[] serialPersistentFields;
private void writeObject(java.io.ObjectOutputStream);
private void readObject(java.io.ObjectInputStream);
java.lang.Object writeReplace();
java.lang.Object readResolve();
}
-assumenosideeffects class android.util.Log {
public static boolean isLoggable(java.lang.String, int);
public static int v(...);
public static int i(...);
public static int w(...);
public static int d(...);
public static int e(...);
}
-adaptresourcefilenames **.properties,**.gif,**.jpg,**.png,**.xml
-adaptresourcefilecontents **.properties,**.xml
-dontwarn android.**
-dontwarn android.support.**
-dontwarn android.support.design.*
-dontwarn org.objenesis.**
更新
还将以下内容添加到您的proguard文件中。
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-verbose
-ignorewarnings
-repackageclasses ''
-allowaccessmodification
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
-keepattributes *Annotation*, EnclosingMethod
-keepattributes Signature
-keepclassmembers public class cn.sharesdk.**{
<init>(...);
*;
}
-keepclassmembers public class com.sina.**{
<init>(...);
*;
}