2015-10-13 56 views
-2

我面臨的問題來混淆我的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。

請幫忙!!我將高度有義務...

回答

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.** 
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' 
} 
+0

我想上proguard ..你的答案會關閉proguard.Thanks回答。 –

相關問題