0

This is the third time I'm trying to get ProGuard to work.

My project is using LibGDX, and is built using Gradle. The only library I'm using is Kryonet 2.21.

When I run ProGuard, I add the generated .jar as an input. ProGuard automatically adds rt.jar.

Shrinking and Optimization are enabled, Obfuscation is disabled (for now).

If I click process, the output contains A LOT of spam about missing classes, for example:

  • Warning: com.badlogic.gdx.utils.GdxBuild: can't find referenced class com.badlogic.gdx.jnigen.BuildTarget
  • Warning: org.lwjgl.opengl.ContextGLES: can't find referenced class org.lwjgl.opengles.EGL

Further down, something is going wrong with java.lang.String toString(); :

Maybe this is library method 'java.nio.FloatBuffer { java.lang.String toString(); }'

(and a LOT more of this spam).

Then some more, like Maybe this is program method 'org.lwjgl.openal.AL10 { void initNativeStubs(); }'.

ProGuard presents me the following errors:

I have tried several "working" ProGuard configurations for LibGDX, like the one given on my previous question : LibGDX proguard, and https://github.com/libgdx/libgdx/wiki/ProGuard-DexGuard-and-libGDX .

If anyone could help me, I'd be forever grateful.

UPDATE:

I have been trying some more configurations. This is my current one:

-dontobfuscate
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-verbose

-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

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

# 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.** { *; }

The operation fails because of multiple of these exceptions: 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..

Community
  • 1
  • 1
kwantuM
  • 512
  • 6
  • 20
  • Well, I believe proguard is trying to help you already with that output. Perhaps you should follow the instructions? Alternatively you could try to explain exactly what it is you want to achieve and how you are trying to achieve this. An actual question makes answering a lot easier. – p.streef Oct 07 '16 at 07:59
  • Okay.. I don't know why classes are missing. – kwantuM Oct 07 '16 at 08:42
  • If that is "exactly what you are trying to achieve" you did it! Congrats! Hint: a questions usually ends with a questionmark. – p.streef Oct 07 '16 at 09:08
  • 1
    Apparently nobody else knows how to use ProGuard. There is almost 0 documentation about it and it's frustrating as hell. – kwantuM Oct 07 '16 at 09:37
  • I admit I had to struggle too at first using proguard, however I have gotten it to work with libgdx and many other libraries. For testing I would add: -keep class com.badlogic.gdx.** if that works you at least know the problem is in some libgdx class – p.streef Oct 07 '16 at 10:10
  • "-dontobfuscate" if you don't want to obfuscate your code, you may well not use proguard at all... – Fran Marzoa Mar 22 '18 at 19:29
  • Proguard can significantly reduce the size of your binary and might even speed it up. This can be very beneficial especially for mobile applications. – kwantuM Mar 25 '18 at 14:28
  • Proguard removed libgdx library for reducing app size. Maybe adding new rules to it will help – Shubham Agrawal Jul 27 '20 at 07:34

0 Answers0