Simple test program crashes in emulator

Monkey Targets Forums/Android/Simple test program crashes in emulator

BurpyMcFistyGuts(Posted 2013) [#1]
With the following test program :

Import mojo.app
Import mojo.graphics

Class MyApp Extends App
	Method OnCreate()
		Return 0
	End
	
	Method OnLoading()
		Return 0
	End
	
    Method OnRender()
        DrawText "Hello World!",0,0
        Return 0
    End
    
    Method OnResume()
    	Return 0
    End
    
    Method OnSuspend()
    	Return 0
    End
    
    ' Process everything
    Method OnUpdate()
    	Return 0
    End
End

Function Main()
        New MyApp
End


whilst it works okay on Windows & HTML 5 and what not, in the Android 4.2.2 emulator, it starts (screen goes black and then immediately exits).


Xaron(Posted 2013) [#2]
Just to be sure, do you use the latest Monkey (70g) or the experimental one?


Amon(Posted 2013) [#3]
In your OnCreate method add : SetUpdateRate(60)


BurpyMcFistyGuts(Posted 2013) [#4]
I'm using V69

SetUpdateRate(60)

Alas, that didn't help

I have also tried 70(g) with the same results unfortunately.

I have also tried in Genymotion too, but with the same results - will need to get the logs...


therevills(Posted 2013) [#5]
Try adding "Cls" in the OnRender method and just "import mojo", along with SetUpdateRate as Amon as stated.

And since you are not using Strict you can remove the return statements.


Midimaster(Posted 2013) [#6]
did ever run any monkey code on this android emulator? Did you test the code on a real device?

What about this code:
Strict
Import mojo

Class Game Extends App

	Method OnCreate%()
		SetUpdateRate 15
		Return 0
	End	

	Method OnUpdate%()
		If KeyHit(KEY_ESCAPE) Then Error ""
		Return 0
	End	

	Method OnRender%()
		Cls
		Return 0
	End	
	
End

Function Main%()
	New Game
	Return 0
End



BurpyMcFistyGuts(Posted 2013) [#7]
I've reverted to :

Strict

Import mojo.app
' Import mojo.graphics

Class MyApp Extends App
	Method OnCreate%()
		SetUpdateRate(15) 
		Return 0
	End
	
	Method OnLoading%()
		Return 0
	End
	
    Method OnRender%()
    	'Cls(0,0,0)
        'DrawText("Hello World!",0,0)
        Return 0
    End
    
    Method OnResume%()
    	Return 0
    End
    
    Method OnSuspend%()
    	Return 0
    End
    
    ' Process everything
    Method OnUpdate%()
    	Return 0
    End
End

Function Main%()
        New MyApp
        Return 0
End


But the program starts and ends instantly. I cant try on a real device until I get my tablet next week...


therevills(Posted 2013) [#8]
Just import mojo, not mojo.app, also you have the cls commented out...


Supertino(Posted 2013) [#9]
I just do;

Import mojo
Import monkey


I don't worry about importing stuff I wont be using.


BurpyMcFistyGuts(Posted 2013) [#10]
Alas, this still isn't working :

Strict

Import mojo
Import monkey

Class MyApp Extends App
	Method OnCreate%()
		SetUpdateRate(15) 
		Return 0
	End
	
	Method OnLoading%()
		Return 0
	End
	
    Method OnRender%()
    	Cls(0,0,0)
        DrawText("Hello World!",0,0)
        Return 0
    End
    
    Method OnResume%()
    	Return 0
    End
    
    Method OnSuspend%()
    	Return 0
    End
    
    ' Process everything
    Method OnUpdate%()
    	Return 0
    End
End

Function Main%()
        New MyApp
        Return 0
End



Supertino(Posted 2013) [#11]
Sure the emulator is working? I ran the code you just posted and it worked fine on the emulator. I tried a Nexus 4 and a kindle fire 2nd gen AVD.


BurpyMcFistyGuts(Posted 2013) [#12]
Oh yes, it's working okay...

Also got hold on a real Android device and it does work on that. However that is Android 4.0 and not 4.1


therevills(Posted 2013) [#13]
I just do;
Import mojo
Import monkey


You don't have to import monkey, it is automatically imported for you.

@BurpyMcFistyGuts - do you get any error messages?


BurpyMcFistyGuts(Posted 2013) [#14]
No error messages nor anything in the Android log files


Skn3(Posted 2013) [#15]
I get this on emulator running Jelly bean too.

I am using genymotion instead of official emulator. This uses virtualbox to run android. I had the same issue with official emulator too on jelly bean.

I noticed that if I manually run the virtualbox profile installed by genymotion, then monkey apps work. If I run it through genymotion then it crashes silently.

genymotion seems to startup alot quicker than manually starting via virtualbox...

Im sure that is not much help to fix the issue?


BurpyMcFistyGuts(Posted 2013) [#16]
The odd thing is that it works fine in Bluestacks, which is currently my prefered Android emulator.

It seems that a Monkey APK file is only compatible with Android 4.1 and below...


Supertino(Posted 2013) [#17]
I can confirm I have created APK's (version 70g - not tried the latest) works with 4.2.2 on emulator and real device.

@Burby does the emulator boot ok into the android OS but then fail when it tries to run the APK? are you using the official Nexus or Kindle AVD's?


BurpyMcFistyGuts(Posted 2013) [#18]
The both emulators boots fine (and other APK files - like GLBasic ones - work fine). It just fails to run the APK properly.

Was using the Nexus AVD

Could upload a video of it if you like (with Google's emulator)