2016-12-09 7 views
0

私はproguardを使ってAndroidアプリケーションをビルドしましたが、APKを逆コンパイルした後、難読化しなければならないクラスは通常のソースを持っています。私のGradleのビルドの一部があります:Android proguardはクラスを難読化していません

buildTypes { 
    debug { 
     minifyEnabled false 
     proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 
    } 
    release { 
     minifyEnabled true 
     proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 
    } 
} 

そして、ここでは私のproguard-rules.proファイルです:

-dontpreverify 
-repackageclasses '' 
-allowaccessmodification 
-keepattributes *Annotation* 

-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.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 * implements android.os.Parcelable { 
    static android.os.Parcelable$Creator CREATOR; 
} 

-keepclassmembers class **.R$* { 
    public static <fields>; 
} 

-keep public class * extends android.support.v4.app.Fragment 
-keep public class * extends android.app.Fragment 

-keepnames class * implements java.io.Serializable 

-keepclassmembers class * implements java.io.Serializable { 
    static final long serialVersionUID; 
    private static final java.io.ObjectStreamField[] serialPersistentFields; 
    !static !transient <fields>; 
    !private <fields>; 
    !private <methods>; 
    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 *** e(...); 
    public static *** w(...); 
    public static *** wtf(...); 
    public static *** d(...); 
    public static *** v(...); 
} 

-keepclasseswithmembernames class * { 
    native <methods>; 
} 
-keepclassmembers class * { 
    public void *ButtonClicked(android.view.View); 
} 

-dontwarn okio** 
-dontwarn java.lang.invoke** 
-dontwarn org.apache.commons.io** 
-dontwarn org.codehaus** 
-keep public class java.nio** 
-dontwarn android.support.v4.** 
-keep class android.support.v4.** { *; } 
-dontwarn android.support.v7.** 
-keep class android.support.v7.** { *; } 
-keep class net.sqlcipher.** { *; } 

-keep class net.sqlcipher.database.** { *; } 

-keep class retrofit2.** { *; } 
-keepattributes Signature 
-keepattributes Exceptions 
-keepclasseswithmembers class * { 
    @retrofit2.http.* <methods>; 
} 
-keep class com.squareup.okhttp.** { *; } 
-keep interface com.squareup.okhttp.** { *; } 
-keep class com.google.gson.** { *; } 
-keep class com.google.inject.* { *; } 
-keep class org.apache.http.** { *; } 
-keep class org.apache.james.mime4j.** { *; } 
-keep class javax.inject.** { *; } 
-keepclassmembernames interface * { 
    @retrofit.http.* <methods>; 
} 

-keep class sun.misc.Unsafe { *; } 
-keep public class !com.vidal.cardio.datas.MySQLCipherOpenHelper { *; } 
-keep public class !com.vidal.cardio.datas.SCLcipherOpenHelper { *; } 

はまあ、私はMySQLCipherOpenHelperSCLcipherOpenHelperを難読化することが期待しましたが、実際に彼らがドン't。 proguard-rules.proに間違いがあるのでしょうか?

+0

可能な複製(http://stackoverflow.com/questions [活動にProGuardの難読化doesntの仕事?]/40811898/proguard-obfuscation-doesnt-work-on-activities) –

答えて

1

あなたはこの

-keep public class !com.vidal.cardio.datas.MySQLCipherOpenHelper { *; } 
-keep public class !com.vidal.cardio.datas.SCLcipherOpenHelper { *; } 

ようなルールを記述する場合は、ProGuardは、次の操作を行いますので、互いに独立して分析され、処理されるルールを保管してください:

  • プロセス以外のすべてを維持するための最初のルールをMySQLCipherOpenHelper
  • SCLcipherOpenHelper以外のすべてを保持するための第2のルールを処理する

最初のルールでは暗黙のうちに2番目のクラスを保持し、2番目のルールでは最初のルールも暗黙に保持します。

それらの両方を保持しないために、あなたがそのようなルールをマージする必要がありますの

-keep public class !com.vidal.cardio.datas.MySQLCipherOpenHelper, 
        !com.vidal.cardio.datas.SCLcipherOpenHelper { *; } 
+0

ありがとう!できます! –

関連する問題