Android app doesn't run, screen goes black for 10ms

Hi Guys,

I just bought a Nexus 4, running Android 4.2.2, and was eager to try out jME on the phone.
First I tried the .apk file listed here https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:android

  • It gives me a list of examples to choose from, but when I select one, it immidiately exits.

Setup:
I have set the Android Target to 4.2.2
I have enabled running “Unknown Sources” on my phone
I have enabled developer and debug mode on my phone

Then I tried to download the JME Tests app over the Play Store

  • Again I see a list of examples. When I click one the screen renders black for about 200ms, then exits.

I figured this might have been because it was compiled against uncompatible android versions or something, so I wanted to compile my own code. Just a simple unshaded cube.
It downloads the app via the android usb driver, without problem, but i only see a quick black screen on my phone, then it returns to the menu, which rotates back a vertical configuration. However the console continues to print out Android stuff. “My Game” appears in the list of processes on my phone, but my phone returns to the desktop when ever I try to select it.

  • I also put a system.out in the render loop, which is never printed.

This is a section of what is printed in the console

MyGame.debug:
Waiting for device to be ready.. Connect your device now if its not connected yet.
MyGame.install:
Installing E:\Niels\jME\AndroidTest\mobile\bin\MyGame-debug.apk onto default emulator or device...
	pkg: /data/local/tmp/MyGame-debug.apk
Success
5018 KB/s (2723770 bytes in 0.530s)
MyGame.installd:
Starting: Intent { cmp=com.nihal.mygame/.MainActivity }
Logging android device output, cancel build or disconnect device to stop logging.
--------- beginning of /dev/log/main
D/dalvikvm( 2572): GC_CONCURRENT freed 377K, 6% free 9550K/10100K, paused 3ms+1ms, total 19ms
D/AudioStreamOutALSA(  863): mHandle->useCase: HiFi Lowlatency
D/ALSAModule(  863): s_route: devices 0x2 in mode 0
D/ALSAModule(  863): switchDevice: device 2 mode:0
D/ALSAModule(  863): s_is_tmus: mnc_mcc :  23410
D/ALSAModule(  863): s_is_tmus: mnc_mcc :  23410
...
this goes on with a few hundred lines of what I assume is Android logging, producing a few lines every second, even though nothing is displayed on my phone

There is a known issue with nexus 4 and RC2 (probably the version of the apk you tried) int the initialization phase.
This issue has been fixed since then in nightly.

1 Like

Thanks! I am indeed running stable. Trying with nightly.

I have tried to build my code against nightly-2013-03-05. But I still get exactly the same behavior.

Okay, just a small update.

I ran the JME Tests app, and was able to produce the 3D scene by enabling “Use VA instead of VBO”… All but HelloTerrain and HelloEffects seem to work. Seems to be what people describe here too: http://hub.jmonkeyengine.org/forum/topic/jme3-android-renderertests-update/

Is there a way to modify VA/VBO settings through code?

mhh sure you’re using nightly?
I have no problem anymore with my nexus 4.

@nihal said: Okay, just a small update.

I ran the JME Tests app, and was able to produce the 3D scene by enabling “Use VA instead of VBO”… All but HelloTerrain and HelloEffects seem to work. Seems to be what people describe here too: http://hub.jmonkeyengine.org/forum/topic/jme3-android-renderertests-update/

Is there a way to modify VA/VBO settings through code?


sorry i didn’t see this post
There is no way , VBO is selected automatically by the renderer if the android sdk version is >=9.

This shouldn’t be an issue really, my previous question still stands

1 Like
@nehon said: mhh sure you're using nightly? I have no problem anymore with my nexus 4.

I am pretty sure. I normally use stable and rarely run nightly, but it is hard to mistake. I made a compile-time library shown below. This is the only compile-time library used by the app i am using. I have rebuild and run, still same result.

Also I can see that [java]public Box( Vector3f center, float x, float y, float z )[/java] is marked as deprecated, which is in the nightly build, not stable.

One question, how is screen size managed? Does it automatically use the full screen resolution, when running on android, or do I have to specify it in code. The code I am trying to run is very basic, and plain jME code. On PC, this pops up the jME startup window.
[java]
public class Main extends SimpleApplication {

public static void main( String[] args ) {
    Main app = new Main();
    app.start();
}

@Override
public void simpleInitApp() {

    Box b = new Box(Vector3f.ZERO, 1, 1, 1);
    Geometry geom = new Geometry( "Box", b );

    Material mat = new Material( assetManager, "Common/MatDefs/Misc/Unshaded.j3md" );
    mat.setColor( "Color", ColorRGBA.Blue );
    geom.setMaterial( mat );

    rootNode.attachChild( geom );
}

}
[/java]

Hi,

So I have tried to run my app on an emulated Nexus 7 too. But the app crashes. I guess maybe the issue isn’t my phone, but my code or setup…

I also got this stack trace:

I/AndroidHarness( 1221): INFO AndroidHarness 3:34:09 PM Splash Screen Picture Resource ID: 0
I/AndroidHarness( 1221): view is null!
I/AndroidHarness( 1221): Splash Screen Skipped.
E/AndroidHarness( 1221): Class mygame.Main init failed
E/AndroidHarness( 1221): java.lang.NullPointerException
E/AndroidHarness( 1221): 	at android.view.ViewGroup.addViewInner(ViewGroup.java:3338)
E/AndroidHarness( 1221): 	at android.view.ViewGroup.addView(ViewGroup.java:3210)
E/AndroidHarness( 1221): 	at android.view.ViewGroup.addView(ViewGroup.java:3186)
E/AndroidHarness( 1221): 	at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:289)
E/AndroidHarness( 1221): 	at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:279)
E/AndroidHarness( 1221): 	at android.app.Activity.setContentView(Activity.java:1901)
E/AndroidHarness( 1221): 	at com.jme3.app.AndroidHarness.layoutDisplay(AndroidHarness.java:446)
E/AndroidHarness( 1221): 	at com.jme3.app.AndroidHarness.onCreate(AndroidHarness.java:223)
E/AndroidHarness( 1221): 	at android.app.Activity.performCreate(Activity.java:5104)
E/AndroidHarness( 1221): 	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
E/AndroidHarness( 1221): 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
E/AndroidHarness( 1221): 	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
E/AndroidHarness( 1221): 	at android.app.ActivityThread.access$600(ActivityThread.java:141)
E/AndroidHarness( 1221): 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
E/AndroidHarness( 1221): 	at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidHarness( 1221): 	at android.os.Looper.loop(Looper.java:137)
E/AndroidHarness( 1221): 	at android.app.ActivityThread.main(ActivityThread.java:5041)
E/AndroidHarness( 1221): 	at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidHarness( 1221): 	at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidHarness( 1221): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
E/AndroidHarness( 1221): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
E/AndroidHarness( 1221): 	at dalvik.system.NativeStart.main(Native Method)

Just tested on my phone as well. I dug out this message in the console. ( I renamed my package structure )

I/WindowState( 1191): WIN DEATH: Window{42c7e3d0 u0 com.nihal.mygame/com.nihal.mygame.MainActivity}
I/ActivityManager( 1191): Process com.nihal.mygame (pid 4534) has died.
W/ActivityManager( 1191): Force removing ActivityRecord{426b4510 u0 com.nihal.mygame/.MainActivity}: app died, no saved state
W/WindowManager( 1191): Force-removing child win Window{42ca2590 u0 SurfaceView} from container Window{42c7e3d0 u0 com.nihal.mygame/com.nihal.mygame.MainActivity}
W/WindowManager( 1191): Failed looking up window
W/WindowManager( 1191): java.lang.IllegalArgumentException: Requested window android.os.BinderProxy@42b874b8 does not exist
W/WindowManager( 1191): 	at com.android.server.wm.WindowManagerService.windowForClientLocked(WindowManagerService.java:8102)
W/WindowManager( 1191): 	at com.android.server.wm.WindowManagerService.windowForClientLocked(WindowManagerService.java:8093)
W/WindowManager( 1191): 	at com.android.server.wm.WindowState$DeathRecipient.binderDied(WindowState.java:932)
W/WindowManager( 1191): 	at android.os.BinderProxy.sendDeathNotice(Binder.java:433)
W/WindowManager( 1191): 	at dalvik.system.NativeStart.run(Native Method)
I/WindowState( 1191): WIN DEATH: null
D/Zygote  (  861): Process 4534 terminated by signal (11)

It seems that both emulated and real android is having the same problems. Unless someone has a solution to this, I think my approach will be to setup another PC and try to compile my code from there.

It seems that the issue is similar on both emulated and real android. The window or view is null, though I am not sure exactly what is causing this…

did you try to setup a BasicGame and launch it on your phone?

1 Like
@nehon said: did you try to setup a BasicGame and launch it on your phone?

The code I am attempting to run is the BasicGame code. All I am expecting to see is a blue unshaded cube.

I just made a projects from scratch with nightly, and it runs flawlessly on my nexus4.

But…from the lines of the android harness in the stack trace you posted it seems you’re using this revision https://code.google.com/p/jmonkeyengine/source/diff?path=/trunk/engine/src/android/com/jme3/app/AndroidHarness.java&format=side&r=10047&old_path=/trunk/engine/src/android/com/jme3/app/AndroidHarness.java&old=9745
Which is most likely RC2.

idk how you setup your project but the jar that is copied in the android lib folder is not the good one.
Maybe try to check the build.xml script.

1 Like

I thought simply compiling it against the .jar libs/ downloaded with a nightly build, would be enough to change from stable to nightly, but I followed the “official guide” on setting up nightly now, ( https://wiki.jmonkeyengine.org/legacy/doku.php/sdk:update_center )

I have just setup everything on a Windows XP machine ( Another machine ).All of that is working great, but on my XP machine, my phone is just not found by jME SDK. I have uninstalled and reinstalled the android USB drivers over and over again, but no change, using this guide: Install OEM USB drivers  |  Android Developers But still no connection. : /

Tomorrow I will try to setup nightly on my office machine, using the “official guide”. I dont seem to have much luck with this android development so far. :s

Thanks for the support, though.

Great! It is working on my office PC. Doing the proper “official” install of the nightly build did the trick.

Seems I have another separate issue of installing the USB driver correctly on my Windows XP setup, but I can deal with that.

Thank you for your patience @nehon you were right from the very start, it seems.

well…i wasn’t really helpful, you did all the work :stuck_out_tongue:
I’m glad it works now