当使用aspectj时,模糊Android库项目

时间:2013-10-03 14:08:27

标签: android obfuscation proguard

我有Android库项目。有一些带有切入点的.aj文件(aspectJ)。 我需要混淆编译的工件(jar)。当我对它进行模糊处理并将其作为库添加到另一个项目时,方面就会停止工作。 有人可以帮助使用ProGuard进行混淆吗?一些配置示例或任何有用的信息。 可能根本不可能吗?有其他选择吗?

感谢。

1 个答案:

答案 0 :(得分:0)

我还有一个带有方面的android库。我的切入点不适用于我的库代码,而是适用于应用程序的代码(例如,Activity.onCreate上的切入点),因此使用我的库的人们已经期望将他们的android项目设置为AspectJ项目。

没有Proguard,一切都很完美,但是尽管我做了每一个例外,我都能想到如果我的库jar被混淆了,我就无法得到建议。我验证了方面类以及所有方法和字段都保存在映射中。

这是我的proguard配置的最终版本,虽然一切都很好并且没有错误,但没有让方面正常工作:

...some config, the injar included my iajc compiled library project with aspects

-optimizations !code/allocation/variable,!code/simplification/arithmetic,!field/*,!class/merging/*
-optimizationpasses 3
-dontpreverify
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontskipnonpubliclibraryclassmembers
-verbose

-keepattributes Exceptions,InnerClasses,Signature,Deprecated,
                SourceFile,LineNumberTable,*Annotation*,EnclosingMethod

# This is the package of my aspects
-keep class my.package.aspectj.** { *; }
# This is all the public methods that my aspect code calls in to
-keep class my.package.allthethingsmyaspectscall.** { *; }

 ...keep some other classes not related to this

有了这些,我的方面仍然没有适用。

我的解决方案是在安装时将我的方面文件复制到客户端应用程序的项目中,以便它在应用程序类路径中并在构建应用程序时进行编织。