问题描述
- Android studio 混淆代码
-
混淆代码直接报
Information:Gradle tasks [:app:assembleRelease]
:MyLibray:compileLint
:MyLibray:copyReleaseLint UP-TO-DATE
:MyLibray:preBuild UP-TO-DATE
:MyLibray:preReleaseBuild UP-TO-DATE
:MyLibray:checkReleaseManifest
:MyLibray:preDebugAndroidTestBuild UP-TO-DATE
:MyLibray:preDebugBuild UP-TO-DATE
:MyLibray:preDebugUnitTestBuild UP-TO-DATE
:MyLibray:preReleaseUnitTestBuild UP-TO-DATE
:MyLibray:prepareComAndroidSupportAppcompatV72301Library UP-TO-DATE
:MyLibray:prepareComAndroidSupportSupportV42301Library UP-TO-DATE
:MyLibray:prepareReleaseDependencies
:MyLibray:compileReleaseAidl UP-TO-DATE
:MyLibray:compileReleaseRenderscript UP-TO-DATE
:MyLibray:generateReleaseBuildConfig UP-TO-DATE
:MyLibray:generateReleaseAssets UP-TO-DATE
:MyLibray:mergeReleaseAssets UP-TO-DATE
:MyLibray:generateReleaseResValues UP-TO-DATE
:MyLibray:generateReleaseResources UP-TO-DATE
:MyLibray:mergeReleaseResources UP-TO-DATE
:MyLibray:processReleaseManifest UP-TO-DATE
:MyLibray:processReleaseResources UP-TO-DATE
:MyLibray:generateReleaseSources UP-TO-DATE
:MyLibray:processReleaseJavaRes UP-TO-DATE
:MyLibray:compileReleaseJavaWithJavac UP-TO-DATE
:MyLibray:extractReleaseAnnotations UP-TO-DATE
:MyLibray:mergeReleaseProguardFiles UP-TO-DATE
:MyLibray:packageReleaseJar UP-TO-DATE
:MyLibray:compileReleaseNdk UP-TO-DATE
:MyLibray:packageReleaseJniLibs UP-TO-DATE
:MyLibray:packageReleaseLocalJar UP-TO-DATE
:MyLibray:packageReleaseRenderscript UP-TO-DATE
:MyLibray:packageReleaseResources UP-TO-DATE
:MyLibray:bundleRelease UP-TO-DATE
:app:preBuild UP-TO-DATE
:app:preReleaseBuild UP-TO-DATE
:app:checkReleaseManifest
:app:preDebugBuild UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72301Library UP-TO-DATE
:app:prepareComAndroidSupportMultidex101Library UP-TO-DATE
:app:prepareComAndroidSupportRecyclerviewV72301Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42301Library UP-TO-DATE
:app:prepareComCjjMaterialrefeshlayoutLibrary130Library UP-TO-DATE
:app:prepareFinancialPHKXMyLibrayUnspecifiedLibrary UP-TO-DATE
:app:prepareReleaseDependencies
:app:compileReleaseAidl UP-TO-DATE
:app:compileReleaseRenderscript UP-TO-DATE
:app:generateReleaseBuildConfig UP-TO-DATE
:app:generateReleaseAssets UP-TO-DATE
:app:mergeReleaseAssets UP-TO-DATE
:app:generateReleaseResValues UP-TO-DATE
:app:generateReleaseResources UP-TO-DATE
:app:mergeReleaseResources UP-TO-DATE
:app:processReleaseManifest UP-TO-DATE
:app:processReleaseResources UP-TO-DATE
:app:generateReleaseSources UP-TO-DATE
:app:processReleaseJavaRes UP-TO-DATE
:app:compileReleaseJavaWithJavac UP-TO-DATE
:app:compileReleaseNdk UP-TO-DATE
:app:compileReleaseSources UP-TO-DATE
:app:collectReleaseMultiDexComponents UP-TO-DATE
:app:proguardRelease UP-TO-DATE
:app:shrinkReleaseMultiDexComponents FAILED
Error:Execution failed for task ':app:shrinkReleaseMultiDexComponents'.java.io.IOException: The output jar [F:saveYGJYFinancialYGJYappuildintermediatesmulti-dex
eleasecomponentClasses.jar] must be specified after an input jar, or it will be empty.
Information:BUILD FAILED
Information:Total time: 1.666 secs
Information:1 error
Information:0 warnings
Information:See complete output in console这是什么意思?
下面是混淆代码,我基本都屏蔽了!
-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.**
-keepclasseswithmembernames class * { # 保持 native 方法不被混淆
native ;
}
-keepclasseswithmembers class * { # 保持自定义控件类不被混淆
public (android.content.Context, android.util.AttributeSet);
}
-keepclasseswithmembers class * {# 保持自定义控件类不被混淆
public (android.content.Context, android.util.AttributeSet, int);
}
-keepclassmembers class * extends android.app.Activity { # 保持自定义控件类不被混淆
public void (android.view.View);
}
-keepclassmembers enum * { # 保持枚举 enum 类不被混淆
public static *[] values();
public static ** valueOf(java.lang.String);
}
-keep class * implements android.os.Parcelable { # 保持 Parcelable 不被混淆
public static final android.os.Parcelable$Creator ;
}
-keep public class * implements java.io.Serializable{
public protected private *;
}
-keep class com.baidu.*{*;}
-dontwarn com.baidu.**
-keep class com.google.gson.**{*;}
-dontwarn com.google.gson.**
#bcprov-ext-jdk15on
-dontwarn org.bouncycastle.**
#commons-lang-2.4
-dontwarn org.apache.commons.lang.**
#adnroid-async-http-1.4.8
-dontwarn com.loopj.android.http.**
#androidquery
-dontwarn com.androidquery.**
#esb
-dontwarn com.hansy.qhxg.restClient.**
#gson-2.2.4
-dontwarn com.google.gson.**
#httpcore-4.3.jar
-dontwarn org.apache.http.**
#slf4j-api-1.7.5
-dontwarn org.slf4j.**
#universal-img-loader
-dontwarn com.nostra13.universalimageloader.**
解决方案
在 build.gradle 中配置android {
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'),'some-other-rules.txt'......
答案就在这里:Android Studio之代码混淆
解决方案二:
buildTypes {
release {
multiDexEnabled true
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}添加了的
解决方案三:
你没用爱加密吗?支持Android和iOS的