【问题标题】:LibGDX proguardLibGDX proguard
【发布时间】:2016-08-31 11:58:56
【问题描述】:

我一直在尝试缩小我的 libGDX 游戏 .jar 的大小。我一直在努力让 proguard 工作。 Proguard 一直抱怨缺少类,否则输出 .jar 将无法运行。

我已经尝试了我为 libGDX 找到的所有现有配置文件。

有人有设置proguard的经验吗?

【问题讨论】:

  • 这是一个有点过于开放的问题,正如给出的那样,Proguard 没有示例和输出。给我们一个 MCVE,我们会帮助你:stackoverflow.com/help/mcve

标签: java intellij-idea libgdx proguard obfuscation


【解决方案1】:

您可以对 libGDX 使用以下配置:

-dontwarn com.badlogic.gdx.**
-dontnote com.badlogic.gdx.**

-keepclassmembers class com.badlogic.gdx.graphics.Cubemap* { *; }
-keepclassmembers class com.badlogic.gdx.graphics.GL* { *; }

# for Android backend
-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);
}

# for box2d plugin
-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);
}
【解决方案2】:

https://github.com/libgdx/libgdx/wiki/ProGuard-DexGuard-and-libGDX

# To enable ProGuard in your project, edit project.properties
# to define the proguard.config property as described in that file.
#
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in ${sdk.dir}/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the ProGuard
# include property in project.properties.
#
# For more details, see
#   http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
#   public *;
#}

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-05-17
    • 2023-03-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多