FATAL EXCEPTION: GLThread 11

Monkey Targets Forums/Android/FATAL EXCEPTION: GLThread 11

Xaron(Posted 2011) [#1]
Well... I can't run anymore Monkey apps on my Desire HD (not my own, not the examples). I can install any apk but running it leads to an error log...

The main section looks like:
05-24 14:22:23.296 E/AndroidRuntime(14672): FATAL EXCEPTION: GLThread 11
05-24 14:22:23.296 E/AndroidRuntime(14672): java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
05-24 14:22:23.296 E/AndroidRuntime(14672): 	at android.os.Handler.<init>(Handler.java:121)
05-24 14:22:23.296 E/AndroidRuntime(14672): 	at android.app.Dialog.<init>(Dialog.java:145)
05-24 14:22:23.296 E/AndroidRuntime(14672): 	at android.app.AlertDialog.<init>(AlertDialog.java:63)
05-24 14:22:23.296 E/AndroidRuntime(14672): 	at android.app.AlertDialog.<init>(AlertDialog.java:59)
05-24 14:22:23.296 E/AndroidRuntime(14672): 	at android.app.AlertDialog$Builder.create(AlertDialog.java:786)
05-24 14:22:23.296 E/AndroidRuntime(14672): 	at android.app.AlertDialog$Builder.show(AlertDialog.java:801)
05-24 14:22:23.296 E/AndroidRuntime(14672): 	at com.monkey.gxtkApp.Die(MonkeyGame.java:447)
05-24 14:22:23.296 E/AndroidRuntime(14672): 	at com.monkey.gxtkApp.InvokeOnRender(MonkeyGame.java:526)
05-24 14:22:23.296 E/AndroidRuntime(14672): 	at com.monkey.gxtkApp.onDrawFrame(MonkeyGame.java:452)
05-24 14:22:23.296 E/AndroidRuntime(14672): 	at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1363)
05-24 14:22:23.296 E/AndroidRuntime(14672): 	at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1118)
05-24 14:22:23.296 W/ActivityManager(1451):   Force finishing activity com.monkey/.MonkeyGame
05-24 14:22:23.316 E/JavaBinder(14672): Unknown binder error code. 0xfffffff7
05-24 14:22:23.376 I/Process (14672): Sending signal. PID: 14672 SIG: 9
05-24 14:22:23.396 E/SensorService(1451): dropping 1 events on the floor (Broken pipe)
05-24 14:22:23.426 E/InputDispatcher(1451): channel '40bccd40 com.monkey/com.monkey.MonkeyGame (server)' ~ Consumer closed input channel or an error occurred.  events=0x8
05-24 14:22:23.426 E/InputDispatcher(1451): channel '40bccd40 com.monkey/com.monkey.MonkeyGame (server)' ~ Channel is unrecoverably broken and will be disposed!
05-24 14:22:23.426 E/SensorService(1451): dropping 1 events on the floor (Broken pipe)
05-24 14:22:23.466 E/SensorService(1451): dropping 1 events on the floor (Broken pipe) 


I'm lost here... It's not only on my device it's on another real devices as well.

I should add that I run Android V2.3.3 on a rooted device. I don't know if this makes a difference at all but it shouldn't as everything else runs fine.


Xaron(Posted 2011) [#2]
Ok, it has something to do with the AndroidManifest.xml

I noticed the following:

With MonkeyPro38 everything works fine.

With MonkeyPro39c there are the new lines
	<uses-sdk 
		android:minSdkVersion="3"
		android:targetSdkVersion="7" />


Usually the application asks for special rights before installing. So for Monkey apps this was access to SD card for instance. With the lines above it doesn't ask for any special rights at all anymore.

But even without these lines I can't get it to work with MonkeyPro39c.


Xaron(Posted 2011) [#3]
Some more log stuff, after removing these lines I don't get an exception anymore but this:
05-24 15:13:30.786 I/dalvikvm(15894): Could not find method com.hexbattles1942.bb_Init.Init, referenced from method com.hexbattles1942.MonkeyGame.onCreate
05-24 15:13:30.786 W/dalvikvm(15894): VFY: unable to resolve static method 93: Lcom/hexbattles1942/bb_Init;.Init ()I
05-24 15:13:30.786 D/dalvikvm(15894): VFY: replacing opcode 0x71 at 0x0020
05-24 15:13:30.786 D/dalvikvm(15894): VFY: dead code 0x0023-0025 in Lcom/hexbattles1942/MonkeyGame;.onCreate (Landroid/os/Bundle;)V
05-24 15:13:31.066 I/ActivityManager(1451): Process com.hexbattles1942 (pid 15894) has died.
05-24 15:13:31.196 D/dalvikvm(1451): GC_EXPLICIT freed 664K, 35% free 9073K/13767K, external 1694K/2106K, paused 128ms 


Oh, and I get always this warning during compilation:
-dex:
     [echo] Converting compiled files and external libraries into D:\Projekte\warhex\hexbattles.build\android\bin\classes.dex...
    [apply] 
    [apply] trouble processing:
    [apply] class name (com/hexbattles1942/bb_Init) does not match path (com/hexbattles1942/bb_init.class)
    [apply] ...while parsing com/hexbattles1942/bb_init.class
    [apply] ...while processing com/hexbattles1942/bb_init.class
    [apply] 1 warning


My current AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
	package="com.hexbattles1942"
	android:versionCode="1"
	android:versionName="1.0">
	<supports-screens android:resizeable="false"
                  android:smallScreens="true"
                  android:normalScreens="true"
                  android:largeScreens="true"
                  android:anyDensity="true" />	
	<uses-permission android:name="android.permission.INTERNET" />
	<application android:label="HexBattles 1942" android:icon="@drawable/icon">
		<activity 
			android:name="MonkeyGame" 
			android:label="HexBattles 1942"
			android:screenOrientation="landscape"
			android:configChanges="keyboardHidden|orientation"
			android:theme=\"@...;
			<intent-filter>
				<action android:name="android.intent.action.MAIN" />
				<category android:name="android.intent.category.LAUNCHER" />
			</intent-filter>
		</activity>
	</application>
</manifest> 



therevills(Posted 2011) [#4]
With Monkey v39(a,b,c) the minSDK was added and a change to the native java code (glbuffers).

Did you delete your build folder after updating to v39?


marksibly(Posted 2011) [#5]
Hi,

    [apply] trouble processing:
    [apply] class name (com/hexbattles1942/bb_Init) does not match path (com/hexbattles1942/bb_init.class)
    [apply] ...while parsing com/hexbattles1942/bb_init.class
    [apply] ...while processing com/hexbattles1942/bb_init.class
    [apply] 1 warning

That looks way wrong!

Does that happen with the demos in bananas too?

Have you deletd .build dirs? If you don't want to lose the mainfest or something, try just copying MonkeyGame.java from targets/ into the .build dir.


Xaron(Posted 2011) [#6]
Thanks, finally I tracked it down to the root cause which wasn't that easy. First: I always remove all build folders, all examples work fine. I did a clean, fresh MonkeyPro install as well.

So here's the cause. The problem pops up if you want to import a file with the name "init.monkey". Well I do all the initialization stuff there. This example will fail (actually it builds but you get that warning and the app will crash on the device):

test.monkey
Strict

Import mojo
Import init

Global testApp:Test

Function Main:Int()
  testApp = New Test()
  Return 0
End Function

Class Test Extends App
  Method OnCreate:Int()
    Initialize()
    SetUpdateRate(30)
    Return 0
  End Method

  Method OnUpdate:Int()
    Return 0
  End Method
  
  Method OnSuspend:Int()
    Return 0
  End Method
  
  Method OnResume:Int()
    Return 0
  End Method

  Method OnRender:Int()
    Return 0
  End Method

End Class


init.monkey
Strict

Function Initialize:Void()
  'Do something here...
End Function


It works if you replace (and rename)
Import init

with something like:
Import initializer

Phew... Strange? I know. ;) Must have something to do with the bb_init stuff? Is "init" somehow a reserved keyword?


therevills(Posted 2011) [#7]
Nasty!


marksibly(Posted 2011) [#8]
Hi,

> The problem pops up if you want to import a file with the name "init.monkey".

Oops! I know what that is, will fix!


Xaron(Posted 2011) [#9]
HA! Have I found a secret? An easteregg? :)


DGuy(Posted 2011) [#10]
I ran into a similar issue where the cause of the error was far from where it was being caught (via an exception handler) by Monkey.

Hopefully over time more of Monkeys' internals will get wrapped with exception handlers so problems get caught closer to their source ...