简体   繁体   English

Android-JNI 在应用程序中检测到错误的 AndEngine GLES2 的 Proguard 问题

[英]Proguard issue with AndEngine GLES2 in Android-JNI DETECTED ERROR IN APPLICATION

I have developed an app that uses andEngine GLES2 and andEngine's extension Physics2DBox .我开发了一个使用andEngine GLES2andEngine的扩展Physics2DBox的应用程序。 The application has other functionality that doesn't just focus on the andEngine aspect.该应用程序具有其他功能,而不仅仅关注 andEngine 方面。 I have proguard enabled in my app.我在我的应用程序中启用了 proguard。 Now when I build a signed version of my app and navigate to where andEngine is used I get the following stack trace:现在,当我构建我的应用程序的签名版本并导航到使用 andEngine 的位置时,我得到以下堆栈跟踪:

JNI DETECTED ERROR IN APPLICATION: JNI GetMethodID called with pending exception 
java.lang.NoSuchMethodError: no non-static method    
"Lcom/badlogic/gdx/physics/box2d/World;.beginContact(J)V" at long 
com.badlogic.gdx.physics.box2d.World.newWorld(float, float, boolean) (World.java:-2) at void 
com.badlogic.gdx.physics.box2d.World.<init>(com.badlogic.gdx.math.Vector2, boolean 
(World.java:101)
at void org.andengine.extension.physics.box2d.PhysicsWorld.<init 
(com.badlogic.gdx.math.Vector2, boolean, int, int) (PhysicsWorld.java:61) 
at void org.andengine.extension.physics.box2d.PhysicsWorld.<init> . 
(com.badlogic.gdx.math.Vector2, boolean) (PhysicsWorld.java:57)

However, when I use a signed version of the app WITHOUT proguard, it works perfectly.但是,当我在没有 proguard 的情况下使用该应用程序的签名版本时,它运行良好。 So I know it is a proguard issue.所以我知道这是一个proguard问题。

Currently, my app architecture looks like目前,我的应用程序架构看起来像这个 . .

Where you can see that the libraries are modules to my app.您可以在哪里看到这些库是我的应用程序的模块。

Currently, my proguard looks like this:目前,我的 proguard 看起来像这样:

-dontobfuscate

-dontwarn javax.annotation.Nullable
-dontwarn javax.annotation.ParametersAreNonnullByDefault

# Proguard configuration for Jackson 2.x (fasterxml package instead of codehaus package)
-keep class com.fasterxml.jackson.databind.ObjectMapper {
      public <methods>;
      protected <methods>;
}
-keep class com.fasterxml.jackson.databind.ObjectWriter {
    public ** writeValueAsString(**);
}
-keepnames class com.fasterxml.jackson.** { *; }
-dontwarn com.fasterxml.jackson.databind.**
-keep public class com.yelp.**

# Retrofit
-dontwarn okio.**
# Platform calls Class.forName on types which do not exist on Android to determine platform.
-dontnote retrofit2.Platform
# Platform used when running on Java 8 VMs. Will not be used at runtime.
-dontwarn retrofit2.Platform$Java8
# Retain generic type information for use by reflection by converters and adapters.
-keepattributes Signature
# Retain declared checked exceptions for use by a Proxy instance.
-keepattributes Exceptions

# okhttp
-dontwarn okhttp3.**
#-dontwarn okio.**
#-dontwarn javax.annotation.**
-dontwarn org.conscrypt.**
# A resource is loaded with a relative path so the package of this class must be preserved.
-keepnames class okhttp3.internal.publicsuffix.PublicSuffixDatabase


-keep class androidx.** { *; }
-keep interface androidx.** { *; }
-keep class android.support.** { *; }
-keep interface android.support.** { *; }



-dontwarn com.google.**
-dontwarn com.bumptech.glide.load.resource.**

-dontwarn org.apache.avalon.framework.logger.Logger
-dontwarn org.apache.log.**
-dontwarn org.apache.log4j.**
-dontwarn javax.servlet.**

-keep class org.apache.http.**  { *; }
-dontwarn org.apache.http.**

-keep class com.github.mikephil.charting.** { *; }
-dontwarn io.realm.**

-dontwarn com.stripe.android.**
-dontwarn org.bouncycastle.**
-dontwarn com.nimbusds.jose.**

-keep class com.stripe.android.** { *; }
-keep class org.bouncycastle.** { *; }
-keep class com.nimbusds.jose.** { *; }

-keep class com.zomato.photofilters.** {*;}
-keepclassmembers  class com.zomato.photofilters.** {*;}
-dontwarn org.xmlpull.v1.**
-dontnote org.xmlpull.v1.**
-keep class org.xmlpull.** { *; }
-keepclassmembers class org.xmlpull.** { *; }

-ignorewarnings

# RULES FOR ANDENGINE STUFF
-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-verbose

-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
-keep public class com.android.vending.licensing.ILicensingService
-keep class Loader {
    public static void main(...);
}
# note that <methods> means any method
-keepclasseswithmembernames,includedescriptorclasses 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 *;
}
-optimizations!code/simplification/arithmetic,!field/*,!class/merging/*

# END OF RULES FOR ANDENGINE STUFF

With the andEngine GLES2 library and andEngine extension library having the following in their own Gradle files. andEngine GLES2 库和 andEngine 扩展库在它们自己的 Gradle 文件中具有以下内容。

consumerProguardFiles 'proguard-rules.pro'

In your case, it looks like proguard removes the World.class of the box2d extension.在您的情况下,看起来 proguard 删除了 box2d 扩展的 World.class 。 Try to add the following to your proguard rules:尝试将以下内容添加到您的 proguard 规则中:

-keep class com.badlogic.gdx.physics.box2d.** { *; }

So it will don´t touch your box2d files.所以它不会触及你的 box2d 文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM