Apk >>混淆>>应用程序崩溃后闪屏
问题描述:
我面临的问题来混淆我的android App.My应用程序有3个模块。 我启用了使用android studio的应用程序中的proguard。Apk >>混淆>>应用程序崩溃后闪屏
我gradle.build文件如下: -
apply plugin: 'com.android.application'
android {
compileSdkVersion 19
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.scconline"
minSdkVersion 14
targetSdkVersion 14
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile project(':androidHorizontalListView')
compile project(':library')
// compile 'com.google.code.gson:gson:2.2'
compile files('libs/eventbus-2.4.0.jar')
compile files('libs/fastjson.jar')
compile files('libs/itextpdf-5.5.4.jar')
compile files('libs/jsoup-1.8.1.jar')
compile files('libs/ksoap2-android-assembly-3.1.1-jar-with- dependencies.jar')
compile files('libs/mockito-all-1.9.0.jar')
compile files('libs/xmlworker-5.5.4.jar')
compile files('libs/gson-2.2.4.jar')
compile files('libs/gson-2.2.4-javadoc.jar')
compile files('libs/gson-2.2.4-sources.jar')
}
我ProGuard的规则文件如下: -
-dontshrink
-dontoptimize
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-verbose
-keepattributes *Annotation*
-keep public class com.scconline.**
-dontnote com.itextpdf.**
-dontnote org.mockito.**
-dontwarn com.itextpdf.**
-dontwarn org.mockito.**
-dontwarn android.**
-dontwarn android.support.**
-keep class android.support.** { *; }
-keep interface android.support.** { *; }
-keep class android.support.design.widget.** { *; }
-keep interface android.support.design.widget.** { *; }
-dontwarn android.support.design.*
-dontwarn org.objenesis.**
-keep public class * extends android.view.View {
public <init>(android.content.Context);
public <init>(android.content.Context, android.util.AttributeSet);
public <init>(android.content.Context, android.util.AttributeSet, int);
public void set*(...);
}
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet);
}
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet, int);
}
-keepclassmembers class * extends android.content.Context {
public void *(android.view.View);
public void *(android.view.MenuItem);
}
-keepclassmembers class * implements android.os.Parcelable {
static ** CREATOR;
}
-keepclassmembers class **.R$* {
public static <fields>;
}
-keepclassmembers class * {
@android.webkit.JavascriptInterface <methods>;
}
我我的主模块和休息使用上述规则文件两个模块使用默认的规则文件,我也可以在模块中启用proguard。
请帮忙!!我将高度有义务...
答
我用下面的代码在我的proguard相关规则文件。它会解决我的问题。
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-verbose
-ignorewarnings
-repackageclasses ''
-allowaccessmodification
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
-keepattributes *Annotation*, EnclosingMethod
-keepattributes Signature
-keep class com.fasterxml.jackson.**
-keepnames class com.fasterxml.jackson.** { *; }
-keep public class * extends android.support.v4.app.FragmentActivity
-keep public class * extends android.app.Activity
-keep public class * extends com.fasterxml.jackson.**
-keep public class * implements java.io.Serializable
-keep public class com.scconline.response.**
-keepclassmembers public class com.scconline.response.**{
<init>(...);
*;
}
-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.**
-dontwarn com.fasterxml.jackson.databind.**
答
使用此:
apply plugin: 'com.android.library'
android {
compileSdkVersion 17
buildToolsVersion "21.1.2"
defaultConfig {
minSdkVersion 5
targetSdkVersion 17
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:18.0.0'
}
我想上proguard ..你的答案会关闭proguard.Thanks回答。 –