我正试图让ProGuard开始工作,经过了大约4个小时的随机尝试,尝试让这个神奇的软件开始工作。
我的项目是使用LibGDX和KryoNet。这是我当前的ProGuard配置:
-verbose
-dontobfuscate
-dontwarn android.support.**
-dontwarn com.badlogic.gdx.backends.android.AndroidFragmentApplication
-dontwarn com.badlogic.gdx.utils.GdxBuild
-dontwarn com.badlogic.gdx.jnigen.BuildTarget*
-dontwarn com.badlogic.gdx.graphics.g2d.freetype.FreetypeBuild
-keepclassmembers class com.badlogic.gdx.backends.android.AndroidInput* {
<init>(com.badlogic.gdx.Application, android.content.Context, java.lang.Object, com.badlogic.gdx.backends.android.AndroidApplicationConfiguration);
}
# Kryo
-dontwarn sun.reflect.**
-dontwarn java.beans.**
-dontwarn sun.nio.ch.**
-dontwarn sun.misc.**
-keep class com.esotericsoftware.kryo.** {*;}
-keep class com.esotericsoftware.** {*;}
-keep class java.beans.** { *; }
-keep class sun.reflect.** { *; }
-keep class sun.nio.ch.** { *; }这不编译。它引发以下多个错误:Uncaught translation error: com.android.dx.cf.code.SimException: local variable type mismatch: attempt to set or access a value of type float using a local variable of type int. This is symptomatic of .class transformation tools that ignore local variable information.
我发现了一些关于这个错误的信息:Compile with Proguard gives SimException: "local variable type mismatch"。
给出的解决方案是从ANT中编辑一些main-rues.xml文件,但我使用的是Gradle。发布了一条评论,并对Gradle进行了修正:添加project.tasks.withType(com.android.build.gradle.tasks.Dex) { additionalParameters=['--no-locals'] }。但是很明显Dex类被删除了,所以这不再有效。
我读到这是ProGuard中的一个bug,而这种混淆应该会修复它。但是当我删除-dontobfuscate行时,我的应用程序就不再启动了:java.lang.UnsatisfiedLinkError: No implementation found for void com.a.a.c.a.k.g() (tried Java_com_a_a_c_a_k_g and Java_com_a_a_c_a_k_g__)。
有人知道如何解决这些问题吗?
发布于 2016-10-07 11:54:34
这个问题可能与ProGuard的特定优化有关。您可以这样禁用它:
-optimizations !code/allocation/variable此外,您还可以删除LocalVariableTable和LocalVariableTypeTable属性,这些属性似乎没有被正确更新(并且在应用程序中不再需要)。为此,您需要启用混淆,然后使用如下内容:
-keepattributes !LocalVariable*,**此规则将保留所有属性,但保留与LocalVariable相关的属性。
libGDX的混淆问题可以通过以下规则来解决:
# Keep names - Native method names. Keep all native class/method names.
-keepclasseswithmembers,includedescriptorclasses class * {
native <methods>;
}https://stackoverflow.com/questions/39915959
复制相似问题