如何在Eclipse中模糊我的代码? (机器人)
作者:互联网
我是Android应用程序的新手.我编写了一个应用程序,需要在eclipse中对其进行模糊处理.我尝试使用以下教程:
http://developer.android.com/tools/help/proguard.html
但是当我创建我的项目时,eclipse没有产生任何“proguard.cfg”文件.我只有一个“project.properties”取消注释以下行.
proguard.config = ${} sdk.dir /tools/proguard/proguard-android.txt:proguard-project.txt
我把{sdk.dir}路径改为sdk.我也没有progurd-android.txt.对于初学者如何在android中混淆代码是否有任何明确的步骤?
或者你有可能为我解释一下吗?
感谢帮助.
解决方法:
首先,你应该在project.ptoperties上注释掉这一行:
proguard.config = ${} sdk.dir /tools/proguard/proguard-android.txt:proguard-project.txt
然后你应该把你的规则编写到proguard-project.txt这是一个来自http://proguard.sourceforge.net/#manual/examples.html的例子:
-injars bin/classes
-injars libs
-outjars bin/classes-processed.jar
-libraryjars /usr/local/java/android-sdk/platforms/android-9/android.jar
-dontpreverify
-repackageclasses ''
-allowaccessmodification
-optimizations !code/simplification/arithmetic
-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 * 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>;
}
然后你应该签名并导出你的apk.如果你不签名混淆不起作用.
标签:android,eclipse,proguard,obfuscation 来源: https://codeday.me/bug/20190728/1563298.html