Problems compiling for Android on Mac

Monkey Targets Forums/Android/Problems compiling for Android on Mac

Leon Brown(Posted 2012) [#1]
Hi. I've set up Monkey to compile for Android on my Mac and the ANDROID_PATH setting is pointing at the correct location for the Android SDK I've downloaded, but I'm getting the following error:

TRANS FAILED: TRANS Failed to execute 'adb start-server', return code=32512
sh: adb: command not found


Can anyone tell me what I need to do to get compile to work? I have a tablet connected to my Macbook for the app to be compiled to.


therevills(Posted 2012) [#2]
I havent actually used a Mac to compile for Android, but that looks like it can't find the Android SDK Tools.

A quick Google:

http://stackoverflow.com/questions/7609270/not-able-to-access-adb-in-os-x-through-terminal-command-not-found


Leon Brown(Posted 2012) [#3]
Figured out that the SDK needed to be compiled, but now there is another error coming up:

The Android Ant-based build system requires Ant 1.8.0 or later. Current version is 1.7.1


I've tried to find out how to update Ant, but no luck so far.


MikeHart(Posted 2012) [#4]
start the ANDROID tool in the TOOLS folder. It will show you what to update and what to install. Using Android on OSX with Monkey is a piece of cake.


Leon Brown(Posted 2012) [#5]
I used the Android tool in the tools folder and it was great how it automatically downloaded all of the files, but it doesn't update Ant - and I don't know where this is meant to be updated.


matt(Posted 2012) [#6]
what do you get from this?
$ whereis ant

and this?
$ /path/shown/in/above/output/to/ant -version

and this?
$ echo $PATH


Ant comes with OS X as default, but you may have a second/older copy being caught sooner than the proper one


Leon Brown(Posted 2012) [#7]
Hi Matt. You posted exactly what I've been looking at all day. I installed a new version of Ant, but it was still using an old version. However, I installed the latest update of Mac OS 10.6 and Java for Mac OS and this solves the problem. However, the next error is as follows:

error: device offline
BUILD FAILED


I've attached my Android device to my Mac and have set USB debugging on, so not sure why it fails.

I've got the app working with an emulator, but not real devices.

**NOTE TO MARK SIBLY*** You should update the instructions to:

* Show how to build the Android SDK on Mac OS - it's not clear that you have to select the Android tool in the tools folder from the instructions provided; I only found this out because I checked the readme file.

* Ensure that the user is using the latest version of Java for Mac OS - older versions of Mac OS come with Ant 1.7.1, which doesn't work with Monkey. The latest version of Java for Mac OS comes with Ant 1.8 and solves the problem - although users also need to have Mac OS 10.6.8 to install the new version.


Leon Brown(Posted 2012) [#8]
Hi Matt. You posted exactly what I've been looking at all day. I installed a new version of Ant, but it was still using an old version. However, I installed the latest update of Mac OS 10.6 and Java for Mac OS and this solves the problem. However, the next error is as follows:

error: device offline
BUILD FAILED


I've attached my Android device to my Mac and have set USB debugging on, so not sure why it fails.

I've got the app working with an emulator, but not real devices. Also, the app fails to work (just shows a blank screen) when compiling for Android 2.2. - can Monkey compile for this? The same thing happens when compiling for iOS - any suggestions?

**NOTE TO MARK SIBLY*** You should update the instructions to:

* Show how to build the Android SDK on Mac OS - it's not clear that you have to select the Android tool in the tools folder from the instructions provided; I only found this out because I checked the readme file.

* Ensure that the user is using the latest version of Java for Mac OS - older versions of Mac OS come with Ant 1.7.1, which doesn't work with Monkey. The latest version of Java for Mac OS comes with Ant 1.8 and solves the problem - although users also need to have Mac OS 10.6.8 to install the new version.


Leon Brown(Posted 2012) [#9]
Just an update - some strange things happen when compiling for Android:

* Apps compile to my phone (HTC Desire) without a problem - even though it says the transfer failed, they appear ok.

* Apps don't appear at all on my tablet (Arnova 9 G2), but they work fine if you manually transfer them with an SD card.

Thanks for all the advice everyone - who would have guessed compiling for Android would be so awkward!


NoOdle(Posted 2012) [#10]
wait a sec, I can compile android on mac?


Leon Brown(Posted 2012) [#11]
Yes, it was tricky to set up, but I got there in the end. Make sure you have the latest version of Java installed. You will need to have at least Mac OS 10.6.8 to do this - or you can try to manually install Ant 1.8 or later on older Mac OS, but it was to difficult to do that for me.

Here's the link you will want:

http://support.apple.com/kb/DL1516


NoOdle(Posted 2012) [#12]
Have you managed to get the emulator running? After much playing I realised I needed to use one, (found a tutorial to set a device up) and that it needs to be open when compiling code. The app starts but I get a com.monkeygame error as soon as it starts.

Any ideas?


Leon Brown(Posted 2012) [#13]
I never had any problem getting the emulator running. You don't need the emulator running to build the app - I've just been hitting build and the appear in the builds/android/bin/monkeygame-debug.api . You can transfer by using a file manager app on Android or transfer via web download. Do you know if it builds? It gives an error to say device not found, but still builds the app.


NoOdle(Posted 2012) [#14]
It builds and starts to run in the emulator but then crashes with an app monkey error. I don't have an android device so I can't test it on that and so far I haven't worked out how to run the compiled output folder....

bit of an android noob tbh :P


MikeHart(Posted 2012) [#15]
What I noticed is that it looks like every other compile, it will transfer the app to the device (HTC Desire). But I am testing mostly on HTML5 anyway and only for some crucial tests I will upload it to the device.


NoOdle(Posted 2012) [#16]
I was hoping to test my framework out on Android to find any problems. Works on iOS, html5, glfw and flash but I'm apprehensive to just trust it will work on Android too. I need a friend with an old droid device!


NoOdle(Posted 2012) [#17]
Oh nice, just got it working, had to run android from tools sdk folder and setup my AVD correctly - it defaulted to a very old Android SDK which I guess was causing my error.