Iāve been having a look at this, as I too plan to obfuscate my game when the time comes. It turns out I get exactly the same exception as you. In fact, if you create a new BasicGame project and build it with obfuscation, youāll get the same exception.
It seems that any enums, even ones you add to your own code, cause this exception. After looking at the ProGuard Usage webpage, and quite a lot of trial and error, Iāve found that this setting fixes it:
-keep enum * {
public static **[] values();
}
This basically means donāt obfuscate any enums. Unfortunately, although it does obfuscate the enum membersā names, the String values of those members remain the same, so, people will be able to see what the enum member names originally were.
The next exception I get with BasicGame is this:
Exception in thread "LWJGL Renderer Thread" java.lang.NoSuchMethodError: getPointer
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(Unknown Source)
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.load0(Unknown Source)
at java.lang.System.load(Unknown Source)
at org.a.q.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at org.a.p.a(Unknown Source)
at org.a.p.<clinit>(Unknown Source)
at com.jme3.system.a.a.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
I really have no idea what the problem here is, exactly, but, a simple fix is to add this:
-keep class org.lwjgl.** {*;}
Thatās enough to get an obfuscated BasicGame to work.
Iām also using annotations, which also cause NullPointerExceptions. The fix for this is just to add this setting:
-keepattributes *Annotation*
Donāt know why that gets highlighted in pink⦠
The other exception I get is because Iām using the Oto model.
java.lang.ClassNotFoundException: com.jme3.scene.Node
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at com.jme3.export.d.a(Unknown Source)
at com.jme3.export.d.a(Unknown Source)
at com.jme3.export.binary.BinaryImporter.readObject(Unknown Source)
at com.jme3.export.binary.BinaryImporter.load$64a6d5d3(Unknown Source)
at com.jme3.export.binary.BinaryImporter.load(Unknown Source)
at com.jme3.export.binary.BinaryImporter.load(Unknown Source)
at com.jme3.asset.l.a(Unknown Source)
at com.jme3.asset.l.a(Unknown Source)
at com.jme3.asset.l.c(Unknown Source)
at botwar.l.g(Unknown Source)
at botwar.a.a(Unknown Source)
at com.jme3.app.a.c.a(Unknown Source)
at com.jme3.app.SimpleApplication.update(Unknown Source)
at com.jme3.system.a.a.l(Unknown Source)
at com.jme3.system.a.g.l(Unknown Source)
at com.jme3.system.a.a.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Apr 20, 2016 7:42:11 PM com.jme3.app.b handleError
SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]
com.jme3.asset.d: Error occured while loading asset "Models/Oto/Oto.mesh.j3o" using BinaryImporter
at com.jme3.asset.l.a(Unknown Source)
at com.jme3.asset.l.a(Unknown Source)
at com.jme3.asset.l.c(Unknown Source)
at botwar.l.g(Unknown Source)
at botwar.a.a(Unknown Source)
at com.jme3.app.a.c.a(Unknown Source)
at com.jme3.app.SimpleApplication.update(Unknown Source)
at com.jme3.system.a.a.l(Unknown Source)
at com.jme3.system.a.g.l(Unknown Source)
at com.jme3.system.a.a.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Looking at the j3o files that come with jMonkeyPlatform, they all have references to lots of non-obfuscated JME3 classes. Iām not sure whether this is always necessarily the case with j3o files though, as I havenāt got around to creating my own models and turning them into j3o files yet. If it is always the case, then it makes obfuscation harder.
The best solution I can come up with to add each of the classes in the j3o as -keep options, which for Oto.mesh.j3o is as follows:
-keep class com.jme3.animation.BoneTrack
-keep class com.jme3.math.ColorRGBA
-keep class com.jme3.animation.AnimControl
-keep class com.jme3.animation.CompactQuaternionArray
-keep class com.jme3.material.MatParam
-keep class com.jme3.animation.Bone
-keep class com.jme3.material.MatParamTexture
-keep class com.jme3.math.Vector3f
-keep class com.jme3.math.Quaternion
-keep class com.jme3.material.Material
-keep class com.jme3.scene.VertexBuffer
-keep class com.jme3.animation.Skeleton
-keep class com.jme3.animation.CompactVector3Array
-keep class com.jme3.animation.Animation
-keep class com.jme3.bounding.BoundingBox
-keep class com.jme3.math.Transform
-keep class com.jme3.light.LightList
-keep class com.jme3.asset.TextureKey
-keep class com.jme3.scene.Mesh
-keep class com.jme3.animation.SkeletonControl
-keep class com.jme3.texture.Texture2D
-keep class com.jme3.scene.Geometry
-keep class com.jme3.scene.Node
This obfuscates the contents of those classes, but not the class names or packages.