Problem loading model in android

Hello,

I want to import a 3D model in an android demo scene.

My model is in the android asset directory.

When I try to call :

[java] Spatial teaGeom = assetManager.loadModel("Models/test/test_model.j3o"); [/java]

it returns a null pointer exception.

Does any body has a tip for me to import models with android?



Thank you.

What is the exception and stack trace?

[java]

01-01 00:16:15.647: WARN/PackageManager(1942): Code path for pkg : jme3test.android2 changing from /data/app/jme3test.android2-1.apk to /data/app/jme3test.android2-2.apk

01-01 00:16:15.647: WARN/PackageManager(1942): Resource path for pkg : jme3test.android2 changing from /data/app/jme3test.android2-1.apk to /data/app/jme3test.android2-2.apk

01-01 00:16:15.857: WARN/RecognitionManagerService(1942): no available voice recognition services found

01-01 00:16:16.497: ERROR/dalvikvm(2468): Could not find class ‘[Ljava.awt.image.BufferedImage;’, referenced from method com.jme3.system.AppSettings.getIcons

01-01 00:16:16.497: WARN/dalvikvm(2468): VFY: unable to resolve check-cast 1750 ([Ljava/awt/image/BufferedImage;) in Lcom/jme3/system/AppSettings;

01-01 00:16:16.507: WARN/dalvikvm(2468): VFY: unable to find class referenced in signature ([Ljava/awt/image/BufferedImage;)

01-01 00:16:16.517: WARN/dalvikvm(2468): VFY: unable to resolve static method 7098: Lcom/jme3/system/JmeSystem;.showSettingsDialog (Lcom/jme3/system/AppSettings;Z)Z

01-01 00:16:16.567: WARN/InputManagerService(1942): Starting input on non-focused client com.android.internal.view.IInputMethodClient$Stub$Proxy@44d779c0 (uid=10024 pid=2027)

01-01 00:16:16.717: WARN/OGLESContext(2468): setSettings.USE_VA: [true]

01-01 00:16:16.717: WARN/OGLESContext(2468): setSettings.VERBOSE_LOGGING: [false]

01-01 00:16:16.857: WARN/dalvikvm(2468): VFY: unable to resolve static method 9449: Ljava/util/Arrays;.copyOf ([Ljava/lang/Object;I)[Ljava/lang/Object;

01-01 00:16:17.109: WARN/AndroidAssetManager(2468): Failed to load resource: Models/test/test_model.j3o

01-01 00:16:17.109: WARN/AndroidAssetManager(2468): java.lang.IllegalArgumentException: Model assets must be loaded using a ModelKey

01-01 00:16:17.109: WARN/AndroidAssetManager(2468): at com.jme3.export.binary.BinaryImporter.load(BinaryImporter.java:106)

01-01 00:16:17.109: WARN/AndroidAssetManager(2468): at com.jme3.asset.AndroidAssetManager.loadAsset(AndroidAssetManager.java:154)

01-01 00:16:17.109: WARN/AndroidAssetManager(2468): at com.jme3.asset.AndroidAssetManager.loadAsset(AndroidAssetManager.java:193)

01-01 00:16:17.109: WARN/AndroidAssetManager(2468): at com.jme3.asset.AndroidAssetManager.loadModel(AndroidAssetManager.java:197)

01-01 00:16:17.109: WARN/AndroidAssetManager(2468): at jme3test.android2.FirstTest.simpleInitApp(FirstTest.java:163)

01-01 00:16:17.109: WARN/AndroidAssetManager(2468): at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:223)

01-01 00:16:17.109: WARN/AndroidAssetManager(2468): at com.jme3.system.android.OGLESContext.initInThread(OGLESContext.java:130)

01-01 00:16:17.109: WARN/AndroidAssetManager(2468): at com.jme3.system.android.OGLESContext.onSurfaceCreated(OGLESContext.java:217)

01-01 00:16:17.109: WARN/AndroidAssetManager(2468): at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1317)

01-01 00:16:17.109: WARN/AndroidAssetManager(2468): at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1116)

01-01 00:16:17.167: WARN/dalvikvm(2468): threadid=8: thread exiting with uncaught exception (group=0x4001d8e8)

01-01 00:16:17.177: ERROR/Application(2468): Uncaught exception thrown in Thread[GLThread 9,5,main]

01-01 00:16:17.177: ERROR/Application(2468): java.lang.NullPointerException

01-01 00:16:17.177: ERROR/Application(2468): at jme3test.android2.FirstTest.simpleInitApp(FirstTest.java:169)

01-01 00:16:17.177: ERROR/Application(2468): at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:223)

01-01 00:16:17.177: ERROR/Application(2468): at com.jme3.system.android.OGLESContext.initInThread(OGLESContext.java:130)

01-01 00:16:17.177: ERROR/Application(2468): at com.jme3.system.android.OGLESContext.onSurfaceCreated(OGLESContext.java:217)

01-01 00:16:17.177: ERROR/Application(2468): at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1317)

01-01 00:16:17.177: ERROR/Application(2468): at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1116)



[/java]

and the problematic instruction is :

[java]

Spatial teaGeom = assetManager.loadModel(“Models/test/test_model.j3o”);

teaGeom.setLocalScale(0.02f);

[/java]

It seems that I have to load models with a modelkey.

But when i try doing this :

[java]

Spatial teaGeom = assetManager.loadModel(new ModelKey("Models/test/test_model.j3o"));

[/java]

i have this error :

[java]

01-01 00:19:09.149: ERROR/Application(2543): Uncaught exception thrown in Thread[GLThread 11,5,main]

01-01 00:19:09.149: ERROR/Application(2543): java.lang.UnsupportedOperationException: Not supported yet.

01-01 00:19:09.149: ERROR/Application(2543): at com.jme3.asset.AndroidAssetManager.loadModel(AndroidAssetManager.java:247)

01-01 00:19:09.149: ERROR/Application(2543): at jme3test.android2.Moov3DFirstTest.simpleInitApp(Moov3DFirstTest.java:164)

01-01 00:19:09.149: ERROR/Application(2543): at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:223)

01-01 00:19:09.149: ERROR/Application(2543): at com.jme3.system.android.OGLESContext.initInThread(OGLESContext.java:130)

01-01 00:19:09.149: ERROR/Application(2543): at com.jme3.system.android.OGLESContext.onSurfaceCreated(OGLESContext.java:217)

01-01 00:19:09.149: ERROR/Application(2543): at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1317)

01-01 00:19:09.149: ERROR/Application(2543): at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1116)

[/java]



Is there a another way to load models in an Android demo?

Please try the AndroidAssetManager from

https://colladaviewer.googlecode.com/svn/trunk/AndroidRenderer



This is a complete rewrite and derived from DesktopAssetManager to provide

the same functionality as the desktop version. The version in the jme3 jars has

only basic funktionality.

larynx said:
Please try the AndroidAssetManager from
https://colladaviewer.googlecode.com/svn/trunk/AndroidRenderer

This is a complete rewrite and derived from DesktopAssetManager to provide
the same functionality as the desktop version. The version in the jme3 jars has
only basic funktionality.

Why you keep spreading the android renderer all over the internet? Why is this one not in the android package of jME3?

Thank you with this asset manager it works fine.

Im spreading it all over the internet because problems get reported here which i have long ago fixed and they come in again and again, most problems are: AssetManager, flipped Texture, Input, app lifecylce management, aso



I would be glad to get commit rights for the android part of jme3 and merge my fixes into.

I have also informed antony about the repository.



What would you suggest?

rightclick, team, createpatch and post?



However would be a good idea to give you comit rights if you are one of the few persons currently working on the android stuff

EmpirePhoenix said:
rightclick, team, createpatch and post?


Would be possible, but it would be big, many files and lots of code.
I thought if anyone is interested in merging and reviewing the code they
can always get the latest code from the repository.

I only know about antony working on it, and it seems he doesnt have much time free.

If i would have commit rights it would be much easier for me to keep the android
part in sync with jme and also to add my fixes.

Patch files are always welcome, even when they are long. Also no problem getting svn access at all, PM me your googlecode mail and I add you to the committers list. (make sure you have checked out using httpS, otherwise you cant commit) Svn is made for collaboration and having separate projects and comparing/merging code is definitely costing more nerves than finding out somebody committed changes to that file while I was editing it (which doesn’t happen very often when you commit regularly / instantly). Also, this way people can check the changes on their computer instantly. I never download those “I put up the code including all jME3 stuff and a windows as ISO bootable file here” :wink:

Hi,



When i run a simpleapplication in android activity was returnet a NoSuchMethodError in setEGLContextClientVersion, this method only exists in android 2.2 version.

Jme3 is compatible with android 2.1-update version?

What i have to do to run?

No, jME3 only runs on 2.2 as it needs OpenGLES 2.

So is there a possibility to use now the androidAssetManager. If yes, then how? What paths should i add to it, to make it work?

Nothing, just run your normal application with the android harness. In SDK terms: Make a project, code like normal, then select the Android deployment checkbox. There is no android-specific code for jME3.