2013-06-11 3 views
8

私はapGuを難読化するためにProGuardを使用していますが、クラス名とメソッド名に変更はありません。以前と同じです。変数名のみが変更されます。ProGuardにメソッド名とクラス名をわかりにくくする方法を教えてください。

ほとんどの場合、Activityのようなクラスは継承されません。私のコードにはいくつかの継承がありますが、それは100%自分で書いたものです。

私は結果を確認するためにd2j-dex2jarとjd-guiを使用しています。あなたはその後、コンポーネント(活動、サービスまたはBroadcastReceivers)クラスと、この問題が発生した場合

-keep class com.google.ads.** # Don't proguard AdMob classes 
-dontwarn com.google.ads.** # Temporary workaround for v6.2.1. It gives a warning that you can ignore 

# Add any classes the interact with gson 
-keep class com.revicostudio.gravityrun.playerdata.PlayerData 
-keep class com.revicostudio.gravityrun.playerdata.SettingsDescriptor 
-keep class com.revicostudio.gravityrun.playerdata.ShipStatus 
-keep class com.revicostudio.gravityrun.descriptors.ShipDescriptor 
-keep class com.revicostudio.gravityrun.descriptors.Ships 
-keep class com.revicostudio.gravityrun.game.galaxies.Galaxies 

-keep public class com.badlogic.** {*;} 



##---------------Begin: proguard configuration common for all Android apps ---------- 
-optimizationpasses 5 
-dontusemixedcaseclassnames 
-dontskipnonpubliclibraryclasses 
-dontskipnonpubliclibraryclassmembers 
-dontpreverify 
-verbose 
-dump class_files.txt 
-printseeds seeds.txt 
-printusage unused.txt 
-printmapping mapping.txt 
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/* 

-allowaccessmodification 
-keepattributes *Annotation* 
-renamesourcefileattribute SourceFile 
-keepattributes SourceFile,LineNumberTable 
-repackageclasses '' 

-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.app.backup.BackupAgentHelper 
-keep public class * extends android.preference.Preference 
-keep public class com.android.vending.licensing.ILicensingService 
-dontnote com.android.vending.licensing.ILicensingService 

# Explicitly preserve all serialization members. The Serializable interface 
# is only a marker interface, so it wouldn't save them. 
-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(); 
} 

# Preserve all native method names and the names of their classes. 
-keepclasseswithmembernames class * { 
    native <methods>; 
} 

-keepclasseswithmembernames class * { 
    public <init>(android.content.Context, android.util.AttributeSet); 
} 

-keepclasseswithmembernames class * { 
    public <init>(android.content.Context, android.util.AttributeSet, int); 
} 

# Preserve static fields of inner classes of R classes that might be accessed 
# through introspection. 
-keepclassmembers class **.R$* { 
    public static <fields>; 
} 

# Preserve the special static methods that are required in all enumeration classes. 
-keepclassmembers enum * { 
    public static **[] values(); 
    public static ** valueOf(java.lang.String); 
} 

-keep public class * { 
    public protected *; 
} 

-keep class * implements android.os.Parcelable { 
    public static final android.os.Parcelable$Creator *; 
} 
##---------------End: proguard configuration common for all Android apps ---------- 

##---------------Begin: proguard configuration for Gson ---------- 
# Gson uses generic type information stored in a class file when working with fields. Proguard 
# removes such information by default, so configure it to keep all of it. 
-keepattributes Signature 

# For using GSON @Expose annotation 
-keepattributes *Annotation* 

# Gson specific classes 
-keep class sun.misc.Unsafe { *; } 
#-keep class com.google.gson.stream.** { *; } 

# Application classes that will be serialized/deserialized over Gson 
-keep class com.google.gson.examples.android.model.** { *; } 

##---------------End: proguard configuration for Gson ---------- 
+0

リリースモードでproguardを有効にしましたか?また、apkからファイルを抽出し、あなたのJavaファイルが難読化されているかどうかを確認することができます – Raghunandan

+1

難読化された変数名があるので、proguardが実行されているので、私はそう思っています –

答えて

7

が、これはOKです:

クラスのいくつかが原因でGSONの使用の除外され、ここで私のProGuardの-project.txtです。

Proguardはコンポーネントの名前を難読化しません。


そして、あなたも

-keep class com.revicostudio.gravityrun.playerdata.PlayerData 
-keep class com.revicostudio.gravityrun.playerdata.SettingsDescriptor 
-keep class com.revicostudio.gravityrun.playerdata.ShipStatus 
-keep class com.revicostudio.gravityrun.descriptors.ShipDescriptor 
-keep class com.revicostudio.gravityrun.descriptors.Ships 
-keep class com.revicostudio.gravityrun.game.galaxies.Galaxies 

として定義されたクラスについて、服用している場合は、その名前が原因keepオプションにより、変更することはできません。


-keep public class * { public protected *; }ライン

+0

AndEngineのアクティビティが1つあり、残りのクラスは100%カスタムです。 –

+0

@AdrianAdamczyk私の編集を参照してください...私は今までですか? –

+0

これらのクラスは、GSONシリアライゼーションのために難読化することはできませんが、難読化すべきクラスはたくさんあります。ゲームのロジック部分を含むものはOKです。 –

2

いくつかの時間のクラス名の難読化ですから、ProGuardのファイル内の規則の下に追加「butterknife」 の原因が動作しませんを削除して試してください。

# Butterknife 
-dontwarn butterknife.internal.** 
-keep class butterknife.** { *; } 
-keep class **$$ViewInjector { *; } 
-keepclasseswithmembernames class * { 
    @butterknife.InjectView <fields>; 
} 
-keepclasseswithmembernames class * { 
    @butterknife.OnClick <methods>; 
    @butterknife.OnEditorAction <methods>; 
    @butterknife.OnItemClick <methods>; 
    @butterknife.OnItemLongClick <methods>; 
    @butterknife.OnLongClick <methods>; 
} 

注:上記のルールは、「バターナイフ」を使用している場合にのみ使用してください。 ProGuardのためのコードは、あなたがbutterknifeおよびバージョン7などの古いバージョンを使用している場合、あなたはこれがある

-keepnames class * { @butterknife.Bind *;} 

あなたproguaredルールでこのラインを持っていないことを確認し、この問題の原因に定義

1

Butterknifeの古い指示すべてのクラス名がわかりにくくならないようにします。

バターナイフには以下の設定を使用してください。

# ButterKnife 
-keep class butterknife.** { *; } 
-dontwarn butterknife.internal.** 
-keep class **$$ViewBinder { *; } 

-keepclasseswithmembernames class * { 
    @butterknife.* <fields>; 
} 

-keepclasseswithmembernames class * { 
    @butterknife.* <methods>; 
} 
関連する問題