java.lang.NullPointerException with Arrays
Monkey Forums/Monkey Bug Reports/java.lang.NullPointerException with Arrays
| ||
| This code works fine under HTML5 and XNA, crashes under Android. Monkey v74a. Worked fine in older versions of Monkey.
Import mojo
Class MyApp Extends App
Method OnCreate()
SetUpdateRate 15
End Method
Method OnUpdate()
If TouchHit()
Local polys:Float[150][]
Local f:Float[5]
Local pCount:Int = 1
For Local l:Int = 0 To 4
f[l] = 99.0' Float(s[l])
Next
polys[pCount] = f
pCount += 1
For Local f2:Float[] = EachIn polys
For Local f3:Float = EachIn f2 ' crash here under android
Print("in f:" + (f3))
Next
Next
EndIf
End
Method OnRender()
Cls
DrawText("hello world", 10, 10)
End
End
Function Main()
New MyApp
End
|
| ||
| Hi, Seems to be working OK here - tried in both debug/release mode under 74a and latest version. What sort of crash are you getting? |
| ||
| That's curious. Tested with V74a and V75d. Tested on 2 different devices and BlueStacks emulator. Crashes. Java SDK: jdk1.6.0_21 and jdk1.7.0_40 tested. I/[Monkey]( 5182): Monkey Runtime Error : java.lang.NullPointerException I/[Monkey]( 5182): D:/MonkeyProjects/emptyAppForTesting.monkey<22> I/[Monkey]( 5182): C:/Monkey/modules/mojo/app.monkey<64> E/AndroidRuntime( 5182): FATAL EXCEPTION: main E/AndroidRuntime( 5182): java.lang.NullPointerException E/AndroidRuntime( 5182): at com.monkeycoder.monkeygame.c_MyApp.p_OnUpdate(MonkeyGame.java:2787) E/AndroidRuntime( 5182): at com.monkeycoder.monkeygame.c_GameDelegate.UpdateGame(MonkeyGame.java:2861) E/AndroidRuntime( 5182): at com.monkeycoder.monkeygame.BBGame.UpdateGame(MonkeyGame.java:562) E/AndroidRuntime( 5182): at com.monkeycoder.monkeygame.BBAndroidGame.UpdateGame(MonkeyGame.java:1264) E/AndroidRuntime( 5182): at com.monkeycoder.monkeygame.BBAndroidGame$GameTimer.run(MonkeyGame.java:816) E/AndroidRuntime( 5182): at android.os.Handler.handleCallback(Handler.java:615) E/AndroidRuntime( 5182): at android.os.Handler.dispatchMessage(Handler.java:92) E/AndroidRuntime( 5182): at android.os.Looper.loop(Looper.java:137) E/AndroidRuntime( 5182): at android.app.ActivityThread.main(ActivityThread.java:4921) E/AndroidRuntime( 5182): at java.lang.reflect.Method.invokeNative(Native Method) E/AndroidRuntime( 5182): at java.lang.reflect.Method.invoke(Method.java:511) E/AndroidRuntime( 5182): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1038) E/AndroidRuntime( 5182): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805) E/AndroidRuntime( 5182): at dalvik.system.NativeStart.main(Native Method) E/android.os.Debug( 2137): !@Dumpstate > dumpstate -k -t -z -d -o /data/log/dumpstate_app_error |
| ||
| Ok, can reproduce. Fixed in next update. |
| ||
| Great. |
| ||
| I am getting the exact same Error message as Volker, only/exclusively on Android on v76d, on a Samsung Galaxy Ace. The stacktrace also starts in my Apps OnUpdate() method. I am pretty sure it has to do with android, because I have already realeased the game on iOS without crash reports relating to this. |
| ||
| * Push |
| ||
| With exactly the same code? It's fixed here, and it was a java bug not an android bug so should be fixed everywhere! |
| ||
| Hi, I upgraded to v77c and and now I got a IntegerFormat exception which allowed to track down the bug. I converted from String to Int, although it appeared that the Int was something like "22.19" Using a Float fixed the problem. |