Android build failed

Monkey Targets Forums/Android/Android build failed

Oddball(Posted 2014) [#1]
Hi, first of all I have been able to compile other apps to Android so I believe I have everything set up correctly.

I have recently ported my game Hack, Slash, Loot to monkey x and it compiles and works fine in glfw, Flash, html5, and iOS. But when I've tried to compile it for Android I'm getting the following error.

-compile:
    [javac] Compiling 3 source files to /Users/dave/Dropbox/hsl_mobile/hsl_mobile.build/android/bin/classes
    [javac] /Users/dave/Dropbox/hsl_mobile/hsl_mobile.build/android/src/com/monkeycoder/monkeygame/MonkeyGame.java:30281: error: code too large
    [javac] 	public static c_Theme g_InitMask(){
    [javac] 	                      ^
    [javac] Note: /Users/dave/Dropbox/hsl_mobile/hsl_mobile.build/android/src/com/monkeycoder/monkeygame/MonkeyGame.java uses unchecked or unsafe operations.
    [javac] Note: Recompile with -Xlint:unchecked for details.
    [javac] 1 error

BUILD FAILED
/Users/dave/Documents/android-sdk-macosx/tools/ant/build.xml:713: The following error occurred while executing this line:
/Users/dave/Documents/android-sdk-macosx/tools/ant/build.xml:727: Compile failed; see the compiler error output for details.

Total time: 3 seconds
TRANS FAILED: Android build failed.
Done.


Can anybody help decipher what is wrong as I'm not much of an Android bod myself?


therevills(Posted 2014) [#2]
You and Monkey have managed to exceed Java's 64k method limit.

What are you doing in InitMask? Can you reduce the number of lines?


Oddball(Posted 2014) [#3]
Hmm… It seems my unorthodox coding style has come back to bite me. I have reduced the function size and it compiles, but now I'm getting a runtime error.
E/AndroidRuntime(11067): FATAL EXCEPTION: main
E/AndroidRuntime(11067): java.lang.NullPointerException

I will need to investigate further to get more details.


Oddball(Posted 2014) [#4]
Ok I've solved this now. Apparently in Java an array doesn't initialise as a Null array like it does in the other targets. You have to allocate an array of length 0 to it to become a Null array.
Global myArray:MyClass[]

If myArray Then Print "Not null"  'This will crash

myArray=New MyClass[0]

If myArray Then Print "Not null"  'This will not crash

So there we go.


therevills(Posted 2014) [#5]
That one looks like a Monkey bug, what version of Monkey are you using? If it the latest maybe raise a bug report....