Apk的混淆>>启动画面后应用程序崩溃
Obfuscation of Apk>>Application crashes after splash screen
我面临混淆我的 android App.My 应用程序有 3 个模块的问题。
我使用 android studio 在我的应用程序中启用了混淆器。
我的 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>;
}
我在我的主模块中使用上面的规则文件,其余两个模块使用默认规则文件,我也在其余模块中启用混淆器。
请帮忙!!我将非常感激...
使用这个:
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 规则文件中使用了以下代码。它会解决我的问题。
-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.**
我面临混淆我的 android App.My 应用程序有 3 个模块的问题。 我使用 android studio 在我的应用程序中启用了混淆器。
我的 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>;
}
我在我的主模块中使用上面的规则文件,其余两个模块使用默认规则文件,我也在其余模块中启用混淆器。
请帮忙!!我将非常感激...
使用这个:
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 规则文件中使用了以下代码。它会解决我的问题。
-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.**