ProGuard SimException [英] ProGuard SimException

查看:106
本文介绍了ProGuard SimException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

经过大约4个小时的随机尝试,尝试使ProGuard正常工作之后,我正在尝试使ProGuard正常工作.

I'm trying to get ProGuard to work, after roughly 4 hours of randomly trying options to try and get this amazing software to work.

我的项目正在使用LibGDX和Kryo​​Net.这是我当前的ProGuard配置:

My project is using LibGDX and KryoNet. This is my current ProGuard configuration:

-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.

This does not compile. It throws multiple of the following errors: 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.

我找到了有关此错误的一些信息:使用Proguard进行编译给出SimException:局部变量类型不匹配" .

I found some information about this error: Compile with Proguard gives SimException: "local variable type mismatch".

给出的解决方案是从ANT编辑一些main-rules.xml文件,但是我正在使用Gradle.发布了一个注释,其中包含Gradle的修复程序:添加project.tasks.withType(com.android.build.gradle.tasks.Dex) { additionalParameters=['--no-locals'] }.但是显然Dex类已被删除,因此它不再起作用.

The solution given was to edit some main-rules.xml file from ANT, but I'm using Gradle. A comment was posted with a fix for Gradle : to add project.tasks.withType(com.android.build.gradle.tasks.Dex) { additionalParameters=['--no-locals'] }. But apparently the Dex class is removed, so this no longer works.

我读到这是ProGuard中的错误,而混淆应该解决它.但是,当我删除-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__).

I read this is a bug in ProGuard, and that obfuscating should fix it. But when I remove the -dontobfuscate line, my app does not start anymore: 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__).

有人知道如何解决这些问题吗?

Does anyone know how to work around these issues?

推荐答案

该问题可能与ProGuard的特定优化有关. 您可以这样禁用它:

The problem might be related to a specific optimization of ProGuard. You can disable it like that:

-optimizations !code/allocation/variable

此外,您还可以删除似乎未正确更新(并且应用程序不再需要)的LocalVariableTable和LocalVariableTypeTable属性.为此,您需要启用混淆功能,然后使用以下命令:

Furthermore you can also remove the LocalVariableTable and LocalVariableTypeTable attributes which do not seem to be updated properly (and are not needed in an application anymore). For this you would need to enable obfuscation though and then use something like:

-keepattributes !LocalVariable*,**

该规则将保留与LocalVariable相关的所有属性.

This rule would keep all attributes but the LocalVariable related ones.

libGDX的混淆问题可以通过以下规则解决:

The obfuscation problem with libGDX might be solved by this rule:

# Keep names - Native method names. Keep all native class/method names.
-keepclasseswithmembers,includedescriptorclasses class * {
    native <methods>;
}

这篇关于ProGuard SimException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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