android studio 混淆文件配置

据说android studio 默认将libs的第三方jar包忽略混淆,所以就没有将类似#-libraryjars libs/umeng-analytics-v5.2.4.jar的操作写入到配置文件,只是将-keep class com.umeng.**{*;}和忽略警告的操作写入配置文件。但是发现gradle在.idea/libraries中引入了其他很多jar包以及这些包的存储地址。刚好程序报错中的com.b.a.a.a 就是指的idea/libraries中的一个包中的类,即为com.loopj.android.http.AsyncHttpClient,不知道怎么在混淆配置文件中忽略这些包的混淆。最后通过配置,发现这些包还是被混淆了,不知道怎么才能配置好这些包不被混淆
下面是我的配置文件:
-optimizationpasses 5
-dontusemixedcaseclassnames
-verbose
-dontpreverify
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
-keepattributes Annotation
-keepattributes Signature

-keep class android.**{*;}
-keep public class * extends android.view
-keep public class * extends android.app.Fragment
-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 * extends android.support.V4.**
-keep public class * extends android.vending.licensing.ILicensingService

-dontwarn android.support.v4.**
-keep class * extends android.support.v4.**{*;}
-dontwarn android.support.v7.**
-keep class * extends android.support.v7.**{*;}

/* 将libs文件下的三方包忽略混淆*/
-keep class com.mob.logcolletor.**{ ;}
-dontwarn com.mob.tools.
*
-keep class com.mob.tools.**{ ;}
-dontwarn com.mob.baidu.
*
-keep class com.mob.baidu.**{ ;}
-dontwarn cn.sharesdk.framework.
*
-keep class cn.sharesdk.framework.**{ ;}
-dontwarn cn.sharesdk.system.email.
*
-keep class cn.sharesdk.system.email.**{ ;}
-dontwarn cn.sharesdk.tencent.qq.
*
-keep class cn.sharesdk.tencent.qq.**{ ;}
-dontwarn cn.sharesdk.system.text.
*
-keep class cn.sharesdk.system.text.**{ ;}
-dontwarn cn.sharesdk.wechat.friends.
*
-keep class cn.sharesdk.wechat.friends.**{ ;}
-dontwarn cn.sharesdk.wechat.utils.
*
-keep class cn.sharesdk.wechat.utils.**{ ;}
-dontwarn cn.sharesdk.wechat.favorite.
*
-keep class cn.sharesdk.wechat.favorite.**{ ;}
-dontwarn cn.sharesdk.wechat.moments.
*
-keep class cn.sharesdk.wechat.moments.**{ ;}
-dontwarn com.tencent.
*
-keep class com.tencent..**{ ;}
-keep public interface com.mob.logcolletor.
*
-keep public interface com.mob.tools.**
-keep public interface com.mob.baidu.**
-keep public interface cn.sharesdk.framework.**
-keep public interface cn.sharesdk.system.email.**
-keep public interface cn.sharesdk.tencent.qq.**
-keep public interface cn.sharesdk.system.text.**
-keep public interface cn.sharesdk.wechat.friends.**
-keep public interface cn.sharesdk.wechat.utils.**
-keep public interface cn.sharesdk.wechat.favorite.**
-keep public interface cn.sharesdk.wechat.moments.**

-keepclasseswithmembernames class * {
native ;
}
-keepclassmembers public class * extends android.view.View {
void set*(***);
*** get*();
}
-keepclasseswithmembernames class * {
void onClick*(...);
}
-keepclasseswithmembernames class * {
*** *Callback(...);
}

-keepclasseswithmembernames class * {
public (android.content.Context,android.util.AttributeSet,int);
}
-keepclasseswithmembernames class * {
public (android.content.Context,android.util.AttributeSet);
}

-keepclassmembers class * extends android.app.Activity {
public void (android.view.View);
}
-keepclassmembers enum * {
public static *
[] values();
public static ** valueOf(java.lang.String);
}
-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator ;
}
-keep class org.apache.http.
*{*;}
-keepclassmembers class **.R$* {
public static ;
}

/* 将External Libraries文件下的三方包忽略混淆*/
-libraryjars $USER_HOME$/.gradle/caches/modules-2/files-2.1/com.loopj.android/android-async-http/1.4.8/77bbfe240e437ecb396d982afa0d3bd4f9090ba7/android-async-http-1.4.8.jar
-libraryjars $USER_HOME$/.gradle/caches/modules-2/files-2.1/com.loopj.android/android-async-http/1.4.8/ec314dce534e83c93364388d023625bb8e605e38/android-async-http-1.4.8-sources.jar!
-libraryjars build/intermediates/exploded-aar/com.soundcloud.android/android-crop/1.0.0/jars/classes.jar
-libraryjars build/intermediates/exploded-aar/com.android.support/appcompat-v7/23.0.0/jars/classes.jar
-libraryjars $USER_HOME$/Documents/androidWorkSpace/android-sdk-macosx/extras/android/m2repository/com/android/support/appcompat-v7/23.0.0/appcompat-v7-23.0.0-sources.jar
-libraryjars $USER_HOME$/.gradle/caches/modules-2/files-2.1/com.jakewharton/butterknife/7.0.1/d5d13ea991eab0252e3710e5df3d6a9d4b21d461/butterknife-7.0.1.jar
-libraryjars $USER_HOME$/.gradle/caches/modules-2/files-2.1/com.jakewharton/butterknife/7.0.1/ad53343e57ae0969aaf451a19eef381abe2ad3a1/butterknife-7.0.1-sources.jar
-libraryjars build/intermediates/exploded-aar/com.android.support/cardview-v7/23.0.0/jars/classes.jar
-libraryjars $USER_HOME$/Documents/androidWorkSpace/android-sdk-macosx/extras/android/m2repository/com/android/support/cardview-v7/23.0.0/cardview-v7-23.0.0-sources.jar
-libraryjars build/intermediates/exploded-aar/com.android.support/design/23.0.0/jars/classes.jar
-libraryjars $USER_HOME$/.gradle/caches/modules-2/files-2.1/com.github.bumptech.glide/glide/3.6.1/86b122e640af09b0723e1fa44083c354ba6d9089/glide-3.6.1.jar
-libraryjars $USER_HOME$/.gradle/caches/modules-2/files-2.1/com.github.bumptech.glide/glide/3.6.1/c84c6f18844d9ae76308619008d40277de5e77d3/glide-3.6.1-sources.jar
-libraryjars $USER_HOME$/.gradle/caches/modules-2/files-2.1/com.google.code.gson/gson/2.3/5fc52c41ef0239d1093a1eb7c3697036183677ce/gson-2.3.jar
-libraryjars $USER_HOME$/.gradle/caches/modules-2/files-2.1/com.google.code.gson/gson/2.3/21e31b9298ed677b17fcac6dd0eb0a82ec35adc2/gson-2.3-sources.jar
-libraryjars $USER_HOME$/.gradle/caches/modules-2/files-2.1/org.apache.httpcomponents/httpcore/4.3.2/31fbbff1ddbf98f3aa7377c94d33b0447c646b6e/httpcore-4.3.2.jar
-libraryjars $USER_HOME$/.gradle/caches/modules-2/files-2.1/org.apache.httpcomponents/httpcore/4.3.2/4809f38359edeea9487f747e09aa58ec8d3a54c5/httpcore-4.3.2-sources.jar
-libraryjars build/intermediates/exploded-aar/com.rengwuxian.materialedittext/library/2.1.4/jars/classes.jar
-libraryjars $USER_HOME$/.gradle/caches/modules-2/files-2.1/com.nineoldandroids/library/2.4.0/e9b63380f3a242dbdbf103a2355ad7e43bad17cb/library-2.4.0.jar
-libraryjars $USER_HOME$/.gradle/caches/modules-2/files-2.1/com.nineoldandroids/library/2.4.0/83d41901478fa8795254244acbafd03f14224dab/library-2.4.0-sources.jar
-libraryjars build/intermediates/exploded-aar/com.orhanobut/logger/1.10/jars/classes.jar
-libraryjars build/intermediates/exploded-aar/com.android.support/recyclerview-v7/23.0.0/jars/classes.jar
-libraryjars $USER_HOME$/Documents/androidWorkSpace/android-sdk-macosx/extras/android/m2repository/com/android/support/recyclerview-v7/23.0.0/recyclerview-v7-23.0.0-sources.jar
-libraryjars $USER_HOME$/Documents/androidWorkSpace/android-sdk-macosx/extras/android/m2repository/com/android/support/support-annotations/23.0.0/support-annotations-23.0.0.jar
-libraryjars $USER_HOME$/Documents/androidWorkSpace/android-sdk-macosx/extras/android/m2repository/com/android/support/support-annotations/23.0.0/support-annotations-23.0.0-sources.jar
-libraryjars build/intermediates/exploded-aar/com.android.support/support-v4/23.0.0/jars/classes.jar
-libraryjars build/intermediates/exploded-aar/com.android.support/support-v4/23.0.0/jars/libs/internal_impl-23.0.0.jar
-libraryjars $USER_HOME$/Documents/androidWorkSpace/android-sdk-macosx/extras/android/m2repository/com/android/support/support-v4/23.0.0/support-v4-23.0.0-sources.jar

-dontwarn com.loopj.android.http.**
-keep class com.loopj.android.http.**{ *;}

-dontwarn com.baidu.**
-keep class com.baidu.**{ *;}

-dontwarn com.bumptech.glide.**
-keep class com.bumptech.glide.**{ *;}

-dontwarn com.google.gson.**
-keep class com.google.gson.http.**{ *;}

-dontwarn com.nineoldandroids.**
-keep class com.nineoldandroids.**{ *;}

-dontwarn com.orhanobut.logger.**
-keep class com.orhanobut.logger.**{ *;}

-dontwarn com.rengwuxian.materialedittext.**
-keep class com.rengwuxian.materialedittext.**{ *;}

-dontwarn com.soundcloud.android.crop.**
-keep class com.soundcloud.android.crop.**{ *;}

-ignorewarning
-dump class_files.txt
-printseeds seeds.txt
-printusage unused.txt
-printmapping mapping.txt

1个回答

据说android studio 默认将libs的第三方jar包忽略混淆,所以就没有将类似#-libraryjars libs/umeng-analytics-v5.2.4.jar的操作写入到配置文件,只是将-keep class com.umeng.**{*;}和忽略警告的操作写入配置文件。但是发现gradle在.idea/libraries中引入了其他很多jar包以及这些包的存储地址。刚好程序报错中的com.b.a.a.a 就是指的idea/libraries中的一个包中的类,即为com.loopj.android.http.AsyncHttpClient,不知道怎么在混淆配置文件中忽略这些包的混淆。最后通过配置,发现这些包还是被混淆了,不知道怎么才能配置好这些包不被混淆

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问