Proguard不会混淆GUI组件 [英] Proguard does not obfuscate gui components

查看:161
本文介绍了Proguard不会混淆GUI组件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用ProGuard混淆我的Android应用。这很好。但是我的gui类(扩展了活动性,视图和自发活动)并没有被混淆。这是proguard.cfg

I would like to use ProGuard to obfuscate my Android app. This works fine. But my gui classes, which extends acitvity, view and sherlockactivity are not obfuscated. Here is the proguard.cfg

-injars      bin/classes
-injars      libs
-outjars     bin/classes-processed.jar
-libraryjars C:/Users/android-sdks/platforms/android-17/android.jar


-dontpreverify
-dontoptimize
-repackageclasses ''
-allowaccessmodification
-optimizationpasses 5
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*

-keepattributes *Annotation*

-dontwarn    sun.misc.Unsafe
-dontwarn    com.actionbarsherlock.**
-dontwarn    com.google.common.**

-keep class android.support.v4.app.** { *; } 
-keep interface android.support.v4.app.** { *; } 
-keep class com.actionbarsherlock.** { *; } 
-keep interface com.actionbarsherlock.** { *; } 

-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
-keep public class * extends android.view.ViewGroup
-keep public class * extends android.support.v4.app.Fragment

-keepclassmembers class * extends android.app.Activity { 
public void *(android.view.View);
}
-keepclassmembers class android.support.v4.app.Fragment { 
*** getActivity(); 
public *** onCreate(); 
public *** onCreateOptionsMenu(...); 
}
-keepclassmembers class * extends com.actionbarsherlock.ActionBarSherlock {
public <init>(...); 
}

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

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


-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*(...);
}

-keepclassmembers class * implements android.os.Parcelable {
    static android.os.Parcelable$Creator CREATOR;
}

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

-keepclassmembers class com.brainyoo.brainyoo2android.ui.html.BYJavaScriptInterface {
   public *;
}

首先,我认为由于反射调用而无法混淆活动

First, I thought activities can´t be obfuscated because of the reflection call

myactivity.class

我尝试添加:

- keep public class mypackege.myactivity.class

但是它不能解决问题。有任何想法如何混淆gui元素吗?

But it does not solve the problem. Any ideas how to obfuscate the gui elements?

感谢
Christine

Thanks Christine

推荐答案


但是我的gui类(扩展了acitvit,view和sherlockactivtiy)并未被混淆。

But my gui classes, which extends acitvit, view and sherlockactivtiy are not obfusecated.

这是因为您的ProGuard配置文件说不要混淆它们。此外,这很重要,就像它们被混淆了一样,您的应用将无法运行,因为:

That is because your ProGuard configuration file says to not obfuscate them. Moreover, this is important, as if they are obfuscated, your app will not run, because:


  • Android不会找到您重命名的活动

  • Android不会找到您的活动生命周期方法

  • Android不会找到您的小部件(用于在解释布局时进行反射)资源)

  • 等。

  • Android will not find your renamed activities
  • Android will not find your activity lifecycle methods
  • Android will not find your widgets (for use with reflection in interpreting layout resources)
  • etc.

我试图添加: -keep公共类mypackege.myactivity.class 但这不能解决问题。

那是因为您要告诉ProGuard 混淆该类。

That is because you are telling ProGuard to not obfuscate that class.


任何想法

您不愿意,如果您希望在完成时拥有一个可运行的应用程序。

You don't, if you wish to have a working app when you are done.

这篇关于Proguard不会混淆GUI组件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆