为番石榴ProGuard的配置与混淆和优化 [英] ProGuard configuration for Guava with obfuscation and optimization
问题描述
寻找一个ProGuard的配置为番石榴,将模糊处理和优化,作为默认的设置在网站上没有。
不仅如此,我不能把它导出我的apk文件,我不断收到:
警告:com.google.common.collect.MinMaxPriorityQueue:
找不到引用场'诠释UNSET_EXPECTED_SIZE类
com.google.common.collect.MinMaxPriorityQueue $生成器
您应该检查是否需要指定其他程序罐子。
由于番石榴17.0 ,这是我需要的ProGuard配置:
-dontwarn javax.annotation中。**
-dontwarn javax.inject。**
-dontwarn sun.misc.Unsafe
否则构建失败,类似的警告:
警告:com.google.common.base.Absent:
找不到引用的类javax.annotation.Nullable
(这是因为番石榴使用注解不属于Android的一部分运行(的android.jar)。在这种情况下,它是精刚静音警告。)
如果您使用的是摇篮作为构建工具,上述 ProGuard的-project.txt
和 build.gradle
生产优化,同时使用番石榴模糊APK。
buildTypes {
推出 {
minifyEnabled真
proguardFile文件(ProGuard的-project.txt)
proguardFile getDefaultProguardFile('ProGuard的-的Android optimize.txt)
}
}
或者您可以包括关系是不以jsr305.jar 一>在 build.gradle
相关性:
编译com.google code.findbugs:JSR305:2.0.2
...只有 -dontwarn sun.misc.Unsafe
在ProGuard的配置,但我用preferred -dontwarn
也为的javax
的东西。
Looking for a ProGuard configuration for Guava that will obfuscate and optimize, as the default one that is provided on the website does not.
Not only that I cannot get it to export my apk, I keep getting:
Warning: com.google.common.collect.MinMaxPriorityQueue:
can't find referenced field 'int UNSET_EXPECTED_SIZE' in class
com.google.common.collect.MinMaxPriorityQueue$Builder
You should check if you need to specify additional program jars.
As of Guava 17.0, this is what I needed in ProGuard config:
-dontwarn javax.annotation.**
-dontwarn javax.inject.**
-dontwarn sun.misc.Unsafe
Otherwise build fails with warnings like:
Warning: com.google.common.base.Absent:
can't find referenced class javax.annotation.Nullable
(That's because Guava uses annotations that are not part of Android runtime (android.jar). In this case it's fine to just mute the warnings.)
If you are using Gradle as the build tool, the above proguard-project.txt
and the following in build.gradle
produces an optimised and obfuscated APK while using Guava.
buildTypes {
release {
minifyEnabled true
proguardFile file('proguard-project.txt')
proguardFile getDefaultProguardFile('proguard-android-optimize.txt')
}
}
Alternatively you can include dependecy to jsr305.jar in build.gradle
dependencies:
compile 'com.google.code.findbugs:jsr305:2.0.2'
...with only -dontwarn sun.misc.Unsafe
in ProGuard config, but I preferred using -dontwarn
also for the javax
stuff.
这篇关于为番石榴ProGuard的配置与混淆和优化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!