Apk的混淆>>启动画面后应用程序崩溃

时间:2015-10-13 07:30:04

标签: android apk android-proguard

我面临的问题是混淆我的Android App.My应用程序有3个模块。 我使用android studio在我的应用程序中启用了proguard。

我的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启用到模块。

请帮忙!!我非常有责任......

2 个答案:

答案 0 :(得分:0)

使用此:

    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'
}

答案 1 :(得分: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.**