我希望在 android apklib 文件中混淆非公共方法等,以便我可以与其他人分发 apklib 文件,而不会影响共享我的所有源代码,因为 apklib 包含源代码。
我正在采取的方法是通过在 pom.xml 中启用 proguard.cfg 来混淆库项目中的非公共方法
这是我的 proguard.cfg 的样子
-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-verbose
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
-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
-keepclasseswithmembernames class * {
native <methods>;
}
-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.app.Activity {
public void *(android.view.View);
}
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}
这是我在 Maven 安装时遇到的错误
资源(默认资源)@ libraryprojects-lib1 --- [INFO] 使用 'UTF-8' 编码复制过滤的资源。[INFO] 复制 1 个资源 [INFO] 跳过不存在的 resourceDirectory C:\GSDevelopment\expworkspace\Samples\libraryprojects\libraryprojects-lib1\target\generated-sources\extracted-dependencies\src\main\resources [INFO] [INFO] - -- maven-compiler-plugin:2.5.1:compile (default-compile) @ libraryprojects-lib1 --- [INFO] 将 2 个源文件编译到 C:\GSDevelopment\expworkspace\Samples\libraryprojects\libraryprojects-lib1\target\类 [INFO] [INFO] --- android-maven-plugin:3.3.2:proguard (default-proguard) @ libraryprojects-lib1 --- [INFO] C:\GSDevelopment\tools\java\jdk1.6.0_33\ jre\bin\java [-Xmx512M, -jar, C:\GSDevelopment\tools\android-sdk\tools\proguard\lib\proguard.jar, @proguard.cfg, -injars,,!org/w3c/ ,!java/ ,!javax/\GSDevelopment\expworkspace\Samples\libraryprojects\libraryprojects-lib1\target\proguard-obfuscated.jar', -dump, 'C:\GSDevelopment\expworkspace\Samples\libraryprojects\libraryprojects-lib1\target\proguard\dump.txt', -printseeds, 'C:\GSDevelopment\expworkspace\Samples\libraryprojects\libraryprojects-lib1\target\proguard\seeds.txt', -printusage, 'C:\GSDevelopment\expworkspace\Samples\libraryprojects\libraryprojects-lib1\target\proguard \usage.txt', -printmapping, 'C:\GSDevelopment\expworkspace\Samples\libraryprojects\libraryprojects-lib1\target\proguard\mapping.txt'] [INFO] 注意:有 185 个重复的类定义。[信息] \GSDevelopment\expworkspace\Samples\libraryprojects\libraryprojects-lib1\target\proguard\dump.txt', -printseeds, 'C:\GSDevelopment\expworkspace\Samples\libraryprojects\libraryprojects-lib1\target\proguard\seeds.txt', -printusage, 'C:\GSDevelopment\expworkspace\Samples\libraryprojects\libraryprojects-lib1\target\proguard\usage.txt', -printmapping, 'C:\GSDevelopment\expworkspace\Samples\libraryprojects\libraryprojects-lib1\target\proguard \mapping.txt'] [INFO] 注意:有 185 个重复的类定义。[信息] \GSDevelopment\expworkspace\Samples\libraryprojects\libraryprojects-lib1\target\proguard\dump.txt', -printseeds, 'C:\GSDevelopment\expworkspace\Samples\libraryprojects\libraryprojects-lib1\target\proguard\seeds.txt', -printusage, 'C:\GSDevelopment\expworkspace\Samples\libraryprojects\libraryprojects-lib1\target\proguard\usage.txt', -printmapping, 'C:\GSDevelopment\expworkspace\Samples\libraryprojects\libraryprojects-lib1\target\proguard \mapping.txt'] [INFO] 注意:有 185 个重复的类定义。[信息] -printmapping, 'C:\GSDevelopment\expworkspace\Samples\libraryprojects\libraryprojects-lib1\target\proguard\mapping.txt'] [INFO] 注意:有 185 个重复的类定义。[信息] -printmapping, 'C:\GSDevelopment\expworkspace\Samples\libraryprojects\libraryprojects-lib1\target\proguard\mapping.txt'] [INFO] 注意:有 185 个重复的类定义。[信息] java.io.IOException:输出 jar 为空。您是否指定了正确的“-keep”选项?[INFO] 在 proguard.shrink.Shrinker.execute(Shrinker.java:159) [INFO] 在 proguard.ProGuard.shrink(ProGuard.java:275) [INFO] 在 proguard.ProGuard.execute(ProGuard.java:101) [信息] 在 proguard.ProGuard.main(ProGuard.java:492)
我有两个带有两个私有方法的 java 文件。谁能指出我可能出了什么问题?提前致谢。