Asset Not Found When Opening in Portrait Mode (Android)

Hi there,

I’ve been making a few android applications but for some odd reason when the applications are opened when in portrait mode using t0neg0d I get crashes.

They are constant asset not found exceptions and if I add the necessary assets directly to the proper folders in the Assets directory of the project it will actually work, but I’ve gotten to the point where I can’t get the atlast materials.png out of the t0neg0d folder so I’ve hit a wall.

Any idea why this would be happening in portrait mode, or why it can’t find the default.fnt unless it’s directly in my projects asset directory!

Here is the current error, though this same error has occured with the Default.fnt the Console.fnt the unshaded.j3md and the light.j3md, Once again adding these things directly to the assets folder makes them work.

E/com.jme3.app.AndroidHarness( 2093): com.jme3.asset.AssetNotFoundException: tonegod/gui/style/atlasdef/atlas.png (Flipped) (Mipmapped)
E/com.jme3.app.AndroidHarness( 2093): at com.jme3.asset.DesktopAssetManager.loadAsset(DesktopAssetManager.java:283)
E/com.jme3.app.AndroidHarness( 2093): at com.jme3.asset.DesktopAssetManager.loadTexture(DesktopAssetManager.java:346)
E/com.jme3.app.AndroidHarness( 2093): at com.jme3.asset.DesktopAssetManager.loadTexture(DesktopAssetManager.java:356)
E/com.jme3.app.AndroidHarness( 2093): at tonegod.gui.core.Screen.setUseTextureAtlas(Screen.java:440)
E/com.jme3.app.AndroidHarness( 2093): at mygame.GuiManager.initialize(GuiManager.java:47)
E/com.jme3.app.AndroidHarness( 2093): at com.jme3.app.state.AppStateManager.initializePending(AppStateManager.java:251)
E/com.jme3.app.AndroidHarness( 2093): at com.jme3.app.state.AppStateManager.update(AppStateManager.java:281)
E/com.jme3.app.AndroidHarness( 2093): at com.jme3.app.SimpleApplication.update(SimpleApplication.java:239)
E/com.jme3.app.AndroidHarness( 2093): at com.jme3.app.AndroidHarness.update(AndroidHarness.java:467)
E/com.jme3.app.AndroidHarness( 2093): at com.jme3.system.android.OGLESContext.onDrawFrame(OGLESContext.java:349)
E/com.jme3.app.AndroidHarness( 2093): at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1524)
E/com.jme3.app.AndroidHarness( 2093): at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1248)
E/com.jme3.app.AndroidHarness( 2093):

Thanks for reading!

Hey there, if you are not using the lastest version of TonegodGUI, update it from the SDK.
And I don’t know how you are instantiating the Screen class, try this:

[java]
Screen screen = new Screen(this, “tonegod/gui/style/atlasdef/style_map.gui.xml”);
screen.setUseTextureAtlas(true, “tonegod/gui/style/atlasdef/atlas.png”);
screen.setUseMultiTouch(true);
guiNode.addControl(screen);
screen.setUseKeyboardIcons(true); //Must be called after the Screen is added to the guiNode
[/java]

@turco

I am indeed running the latest version and this problem is not confined to the atlas.png and only affects when opening my application in portrait mode, or reopeing my application after exiting on android.

For some reason it will even claim not to find the default.fnt which suggests that something is not going right behind the scenes, the fact that adding these assets directly to the assets folder works also shows that something may not be initiating in the right order.

Also, I initialize my screen just as you have, but I don’t believe it’s relative to just that.

@BigBob said: @turco

I am indeed running the latest version and this problem is not confined to the atlas.png and only affects when opening my application in portrait mode, or reopeing my application after exiting on android.

For some reason it will even claim not to find the default.fnt which suggests that something is not going right behind the scenes, the fact that adding these assets directly to the assets folder works also shows that something may not be initiating in the right order.

Also, I initialize my screen just as you have, but I don’t believe it’s relative to just that.

Well this (or something very similar to this) happened to me few days ago, I solved it instantiating the Screen like that, thought could be related to the same issue.

Well I got my hands onto the atlas.png and put it directly into my assets folder and I ended up with this error

Which tells me that there may again something going wrong behind the scenes.

This error occurs when I either exit the application and attempt to reopen, or attempt to open in portrait mode, it will attempt to switch around, then come up with the error.

Here is the current error.

E/com.jme3.app.AndroidHarness( 8363): SEVERE Exception thrown in Thread[GLThread 3255,5,main]
E/com.jme3.app.AndroidHarness( 8363): java.lang.NullPointerException
E/com.jme3.app.AndroidHarness( 8363): at tonegod.gui.core.Element.<init>(Element.java:217)
E/com.jme3.app.AndroidHarness( 8363): at tonegod.gui.controls.util.ModalBackground.<init>(ModalBackground.java:26)
E/com.jme3.app.AndroidHarness( 8363): at tonegod.gui.core.Screen.initModalBackground(Screen.java:2457)
E/com.jme3.app.AndroidHarness( 8363): at tonegod.gui.core.Screen.setSpatial(Screen.java:1957)
E/com.jme3.app.AndroidHarness( 8363): at com.jme3.scene.Spatial.addControl(Spatial.java:602)
E/com.jme3.app.AndroidHarness( 8363): at mygame.GuiManager.initialize(GuiManager.java:49)
E/com.jme3.app.AndroidHarness( 8363): at com.jme3.app.state.AppStateManager.initializePending(AppStateManager.java:251)
E/com.jme3.app.AndroidHarness( 8363): at com.jme3.app.state.AppStateManager.update(AppStateManager.java:281)
E/com.jme3.app.AndroidHarness( 8363): at com.jme3.app.SimpleApplication.update(SimpleApplication.java:239)
E/com.jme3.app.AndroidHarness( 8363): at com.jme3.app.AndroidHarness.update(AndroidHarness.java:467)
E/com.jme3.app.AndroidHarness( 8363): at com.jme3.system.android.OGLESContext.onDrawFrame(OGLESContext.java:349)
E/com.jme3.app.AndroidHarness( 8363): at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1524)
E/com.jme3.app.AndroidHarness( 8363): at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1248)
E/com.jme3.app.AndroidHarness( 8363):

Thanks for reading!

@t0neg0d

Can you take a look at this, I just can’t seem to figure it out…

@BigBob said: @t0neg0d

Can you take a look at this, I just can’t seem to figure it out…

Gimme a few to review the thread.

Strange stuff indeed.

Shouldn’t take me long to figure out what the problem is.

Oh… can you post your screen initialization and the style_map.gui.xml file if you are using a custom one?

@t0neg0d

Here you go, and I’m not using a custom style_map.xml

The relevant lines are lines 58-61

Thanks for looking!

Add this line to your screen initialization (I think this is bugged atm… but need to verify)screen.setUseKeyboardIcons(true);

Not sure if this will resolve the entire issue… but it might /shrug

Here is the entire initialization I usually use with Android:

[java]
screen = new Screen(this, “tonegod/gui/style/atlasdef/style_map.gui.xml”);
screen.setUseTextureAtlas(true, “tonegod/gui/style/atlasdef/atlas.png”);
screen.setUseMultiTouch(true);
inputManager.setSimulateMouse(false);
flyCam.setDragToRotate(true);
inputManager.setCursorVisible(true);
guiNode.addControl(screen);
screen.setUseKeyboardIcons(true);
[/java]

EDIT: The cursor related lines are for testing on desktop of course…

Also, you can grab the related code for the emitter from Hose.java in the repo I posted. Remeber, you’ll also need the Emitter System and the Circle.j3o file I am using as an Emitter shape.

@t0neg0d

Unfortunately it didn’t work D’=

I still get the same issue

E/com.jme3.app.AndroidHarness( 8363): at tonegod.gui.core.Element.<init>(Element.java:217)

I’m confident it would also be unable to find the default font if I didn’t add it to my assets

@BigBob said: @t0neg0d

Unfortunately it didn’t work D’=

I still get the same issue

E/com.jme3.app.AndroidHarness( 8363): at tonegod.gui.core.Element.<init>(Element.java:217)

I’m confident it would also be unable to find the default font if I didn’t add it to my assets

Is this a new problem? i.e. The other games you have used the library with didn’t do this, correct?

Just because if I don’t say it… it will be at the back of my brain. Have you run clean & build on the project before running it?

Ah… and what device is this on?

@t0neg0d

All games that use the library also have this bug. But only on android.

This problem occurs

A. When one exits the game and attempts to reopen it.

B. When one attempts to open the game freshly (after a fresh install or force stop) in portrait mode

Perhaps the issue is it is hanging up when attempting to exit the game, in portrait mode,it may exit and then try and restart the app in landscape mode.

Can I see your android MainActivity to see how you destroy or stop the application?

EDIT: Samsung Galaxy Tab 2 is the device

@BigBob said: @t0neg0d

All games that use the library also have this bug. But only on android.

This problem occurs

A. When one exits the game and attempts to reopen it.

B. When one attempts to open the game freshly (after a fresh install or force stop) in portrait mode

Perhaps the issue is it is hanging up when attempting to exit the game, in portrait mode,it may exit and then try and restart the app in portrait mode.

Can I see your android MainActivity to see how you destroy or stop the application?

Surely… one sec

[java]
@Override
public void onDestroy() {
super.onDestroy();
System.runFinalization();
android.os.Process.killProcess(android.os.Process.myPid());
}
[/java]

I can post the entire thing if you want… but it is rather large a riddled with useless crap from testing Google Play Services (only semi-successfully).

Honestly, I’m not sure if the above is properly killing the process or not. It is supposed to… buuuut

I’ll download your project tomorrow and see if I can repro the problem on my tablet. It will be much easier than trying to guess. I know I have seen the ModalWindow error before… and it started when I updated the xml extension /boggle.

As for the asset problem, I’ve never had this… whether I add the assets to the usual asset directories or add them to packages within my apps. Hopefully, I can get this to happen when running you app and track down the issue.

One last question…

Are you using JME’s stable build? Or nightly?

@t0neg0d

Well the error is gone and the game closes properly!

The only issue now is when opening in portrait it closes immediately, which suggests onDestroy() is called when trying to change orientation and now just completely closes the app.

Now I just have to come up with a way to safely restart the application if the destruction is a result of orientation change.

Something just tells me that attempting to reopen the app onDestroy() may not work out well

@BigBob said: @t0neg0d

Well the error is gone and the game closes properly!

The only issue now is when opening in portrait it closes immediately, which suggests onDestroy() is called when trying to change orientation and now just completely closes the app.

Now I just have to come up with a way to safely restart the application if the destruction is a result of orientation change.

Something just tells me that attempting to reopen the app onDestroy() may not work out well

I saw this problem as well. Is this related to the gui library? Or does it happen with all apps? (Stepping back for a moment… is this the error where if you are not holding the device in the proper orientation, it closes? Or is this something else?)