使用proguard时,Libgdx bulletwrapper app崩溃了

时间:2016-12-12 10:12:42

标签: java android libgdx bulletphysics bullet

当我尝试运行使用proguard启用的版本apk时,我的libgdx / bullet应用程序崩溃并出现以下异常:

     Process: com.my.app, PID: 14042
     java.lang.NoSuchMethodError: no static method "Lcom/badlogic/gdx/physics/bullet/linearmath/LinearMathJNI;.SwigDirector_btIDebugDraw_getDefaultColors(Lcom/badlogic/gdx/physics/bullet/linearmath/btIDebugDraw;)J"
         at com.badlogic.gdx.physics.bullet.linearmath.LinearMathJNI.swig_module_init(Native Method)
         at com.badlogic.gdx.physics.bullet.linearmath.LinearMathJNI.<clinit>(Unknown Source)
         at com.badlogic.gdx.physics.bullet.linearmath.LinearMathJNI.btGetVersion(Native Method)
         at com.badlogic.gdx.physics.bullet.linearmath.a.a(Unknown Source)
         at com.badlogic.gdx.physics.bullet.a.a(Unknown Source)
         at com.my.app.i.<init>(Unknown Source)
         at com.my.app.h$1.a(Unknown Source)
         at com.badlogic.gdx.f.a.b.b.a(Unknown Source)
         at com.badlogic.gdx.f.a.b.a(Unknown Source)
         at com.badlogic.gdx.f.a.b.a(Unknown Source)
         at com.badlogic.gdx.f.a.a.a.a(Unknown Source)
         at com.badlogic.gdx.f.a.a.a$1.a(Unknown Source)
         at com.badlogic.gdx.f.a.b.c.a(Unknown Source)
         at com.badlogic.gdx.f.a.g.a(Unknown Source)
         at com.badlogic.gdx.f.a.h.b(Unknown Source)
         at com.badlogic.gdx.backends.android.i.onDrawFrame(Unknown Source)
         at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1548)
         at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1259)

我的应用程序是游戏,只有在游戏屏幕启动时才会发生崩溃,而不是在初始菜单屏幕中。这是我的proguard-project.txt文件:

-verbose

-dontwarn android.support.**
-dontwarn com.badlogic.gdx.backends.android.AndroidFragmentApplication
-dontwarn com.badlogic.gdx.utils.GdxBuild
-dontwarn com.badlogic.gdx.physics.box2d.utils.Box2DBuild
-dontwarn com.badlogic.gdx.jnigen.BuildTarget*
-dontwarn com.badlogic.gdx.graphics.g2d.freetype.FreetypeBuild
-dontwarn com.badlogic.gdx.jnigen.*

-keep class com.badlogic.gdx.controllers.android.AndroidControllers

-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);
}

-keepclassmembers class com.badlogic.gdx.physics.box2d.World {
   boolean contactFilter(long, long);
   void    beginContact(long);
   void    endContact(long);
   void    preSolve(long, long);
   void    postSolve(long, long);
   boolean reportFixture(long);
   float   reportRayFixture(long, float, float, float, float, float);
}

我该如何解决这个问题?我想我需要阻止proguard混淆子弹调用,但无法弄清楚如何去做。

1 个答案:

答案 0 :(得分:1)

-keep class com.badlogic.** { *; }
-keep enum com.badlogic.** { *; }

来源:this gradle file

我也不愿意拥有这么多-dontwarn。应用上述后,看看是否可以删除它们。只有-dontwarn当您知道它确实不是问题并且已经用尽其他方法来修复警告。