Android JMonkey Test Project BitmapFontLoader

Hi,
i downloaded the JmonkeySdk and created a testproject from a template, it compiled and was sucessfully deployed.
It also starts but when i try to execute any other example than the first one i get a nullpointerException in the BitmapFontLoader.java line 63.

The device is a Nexus 7 with Android 4.4, i hope that you can help me and thanks in advance.

I confirm that. Nexus 4. Today updated to Android 4.4. Reinstalled jMonkeyEngine SDK, updated and JMETestsAndroid start successfully, but only TestBareBoneApp works fine. Other tests produce this log cat:
11-26 21:31:19.107: E/com.jme3.app.AndroidHarness(8870): SEVERE Exception thrown in Thread[GLThread 1083,5,main]
11-26 21:31:19.107: E/com.jme3.app.AndroidHarness(8870): java.lang.NullPointerException
11-26 21:31:19.107: E/com.jme3.app.AndroidHarness(8870): at com.jme3.font.plugins.BitmapFontLoader.load(BitmapFontLoader.java:63)
11-26 21:31:19.107: E/com.jme3.app.AndroidHarness(8870): at com.jme3.font.plugins.BitmapFontLoader.load(BitmapFontLoader.java:171)
11-26 21:31:19.107: E/com.jme3.app.AndroidHarness(8870): at com.jme3.asset.DesktopAssetManager.loadAsset(DesktopAssetManager.java:288)
11-26 21:31:19.107: E/com.jme3.app.AndroidHarness(8870): at com.jme3.asset.DesktopAssetManager.loadFont(DesktopAssetManager.java:370)
11-26 21:31:19.107: E/com.jme3.app.AndroidHarness(8870): at com.jme3.app.SimpleApplication.loadGuiFont(SimpleApplication.java:179)
11-26 21:31:19.107: E/com.jme3.app.AndroidHarness(8870): at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:187)
11-26 21:31:19.107: E/com.jme3.app.AndroidHarness(8870): at com.jme3.app.AndroidHarness.initialize(AndroidHarness.java:455)
11-26 21:31:19.107: E/com.jme3.app.AndroidHarness(8870): at com.jme3.system.android.OGLESContext.initInThread(OGLESContext.java:229)
11-26 21:31:19.107: E/com.jme3.app.AndroidHarness(8870): at com.jme3.system.android.OGLESContext.onSurfaceCreated(OGLESContext.java:205)
11-26 21:31:19.107: E/com.jme3.app.AndroidHarness(8870): at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1501)
11-26 21:31:19.107: E/com.jme3.app.AndroidHarness(8870): at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1240)

Hope this will help.

I got more additional info.
Checkouted engine sources from svn and compiled them. On my Htc sensation with Android 4.2 everything works fine, but on Nexus 4 with Android 4.4 I have the above error.
And NullPointerException happens on loading “Interface/Fonts/Default.png (Flipped)”. I really do not know what is it and what to do. May be someone can suggest?

Best regards,
Matvey.

I have the same issue with android 4.4, tested it yesterday night.
Idk what changed. The assetManager loads the file, but it’s blank…
I’ll look into it tonight, and keep you updated.

i don’t have an android but just to try to help :

  1. it can comes from a changement in the policy from android. Like maybe only signed app can now do things they was able to do before.
  2. if you (jme) rely on a lib from android (i.e. a native lib, not something embedded in jme) to load the file, they maybe removed it in their lastest release. As bmp is really an obsolete format, it’s not impossible.
  3. it could come from the new java compiler/jvm, the one you was talking before that is supposed to replace the old one and be faster and cure every world disease.

Things you can test:

  1. try to open the file with only an inputstream. If the problem is a lib problem, the stream won’t be empty. Otherwise, if it’s a security-policy problem, you’ll have an empty stream.
  2. if the stream is not empty, you can try to see if the problem happens with all images or just bmp. If this is true for all images, well … it likely means that jme rely on a native lib and something goes wrong in how jme interract with it.

hope it can help. I’ll try to think more about it.

I just googled “android 4.4 bitmap” and i got this :

there is a part on how bitmap are handled now. They changed something here. (search for “bitmap” in the page :wink: )

(and here https://developer.android.com/training/displaying-bitmaps/manage-memory.html)
(and you can find more, easily)

Well actually BitmapFont has nothing to do with bmp file format. It’s Bitmap as in “image based font”. The problem occur when loading a .fnt file (the font descriptor) that is a plain text file. However this file is stored in Jme3-core.jar, but that hasn’t be a problem until now…
I reproduced the issue with both dalvik vm and ART so that’s a more global issue.

@bubuche said: 1) try to open the file with only an inputstream. If the problem is a lib problem, the stream won't be empty. Otherwise, if it's a security-policy problem, you'll have an empty stream.
Are you absolutely sure about this? because the stream really looks empty...I'm would just be a bit surprised to have an empty stream in that case instead of a proper exception...that's why I'm more inclined to think of a unexpected os behavior...

It’s fixed in last SVN. It was an issue with how we were handling the reading of the text file with a buffered reader.
I guess this is a candidate for JME 3.0.4 because everyone making android games will want it.
In the meantime it’s available in last svn.

Thx for your work! I have reviewed this fix. I tried the nearly same before and it didn’t helped. Game still throwed some exceptions. I’ll try your fix and report the result here.

Ok, i confirm. It’s fixed in last SVN commit. Thanks again.

@nehon When will this be in the nightly, or is there a quick way I can pick up only this fix?

NIghtly is broken again…
you have no choice but o build the svn for now.
As soon as nightly is fixed I’ll make a stable 3.0.4 with this fix.

@nehon Alright. Thanks for the quick response!

How did you get it work on Android 4.4 (KitKat)? I’m interested since I want to use Java 7.

Hi,
I have version 3.0.10 and it still gives me the same error as described in exactly same line. I’m talking here about android in 4.4 version.
Can anybody help in running this on 4.4 ? This thread is the only one I’ve found but still I can’t run my app