How do I setup Android as a target?

Monkey Targets Forums/Android/How do I setup Android as a target?

Arabia(Posted 2013) [#1]
Hi all. First post here, but some of you may recognize my name from the Blitz forums.

Just purchased Monkey a matter of hours ago, and a Samsung Galaxy Tab 3 earlier today.

I've downloaded the Tutorial PDF by James Boyd and starting to work my way though it, but it mentions that it's only concerning itself with the HTML5 target.

Is there a tutorial (or something in the docs that I've missed) that outlines the steps required to add more target platforms to Monkey?

Looking forward to joining the community and hopefully learning some new stuff.


Paul - Taiphoz(Posted 2013) [#2]
Yeah you need to look at Small Time Outlaw's Youtube video tutorials, they are linked in the tutorial forums bellow.

Once you have done a few of those, I would look at Diddy, it's a framework that will help you get a basic game up and running in no time at all, its not the only framework available but its the only one I have used enough to feel confident in recommending it to some one.


muddy_shoes(Posted 2013) [#3]
There's a section called "Target SDKs" in the documentation.


Arabia(Posted 2013) [#4]
Thanks very much.

I probably should get comfortable with the language to start with, but I really do want to get something/anything working on the Galaxy Tab :)


Paul - Taiphoz(Posted 2013) [#5]
Yeah sorry about that post I totally missed what forum I was in and miss-read what you were actually asking for, my bad.

Yeah like Muddy said, in the help is a Target SDK section, which will tell you all the SDK's you need for each target.

You will also need to edit the config file inside the monkey bin folder, called config.winnt.txt for windows, that config file tells monkey where all the SDK's are installed so once you have them downloaded and installed make sure the paths within this file match and point to the right locations.


Arabia(Posted 2013) [#6]
Okay, thanks very much.

I see I need to download a fair bit of stuff which I won't do tonight as I'm on the home broadband account which is limited - I'll go to a library tomorrow and leech off their free internet connection and get everything downloaded that I need.

I did have a quick look at Small Time Outlaw's YouTube vid's and they look awesome - started watching in the wrong order and stuff is flying over my head. Hopefully I'll get it all set up tomorrow - will post more questions if I get stuck.

Thanks for all the help.


Midimaster(Posted 2013) [#7]
there 3 steps to get run something on your smartphone:

1.
You additional need to install all Android related developer setups from the internet:

- apache-ant (0.1 GB)
- java jdk (0.3 GB)
- android sdk (2.5 GB)

2.
Then change the related links in the "C:\Monkey..\bin\config.winnt.txt"

3.
Dont forget to install the USB drivers for your smartphone. After installation you can directly execute monkey code on your smartphone.


Arabia(Posted 2013) [#8]
@midimaster

Thanks mate.

I'll do all of that tomorrow (hopefully!)

Android SDK - 2.5Gb? really? I didn't think it was that big - I started downloading something earlier that was 400Mb+ in size and I cancelled it so I didn't use up all of the home broadband data allowance. 2.5Gb seems like an awful big file - but I'm going to use public broadband (which my taxes pay for) tomorrow so it really doesn't matter how big it is.


Paul - Taiphoz(Posted 2013) [#9]
Yeah the Android SDK Manager is a bitch and its slow as well, at least it is for me, I think you only need the 3.2 sdk for monkey, but dont quote me on that, I dont have limits on my BB so I just downloaded everything, but if your bandwith has a low cap you might want to try and onyl grab the essential stuff and leave the frosting till another time.

OH and welcome and hope you have fun :)


Midimaster(Posted 2013) [#10]
It's like Taiphoz said: Nobody knows exactly what is needed and what not. So many of us downloaded everything.

It starts with the download of the Android SDK Manager, which itself will download a lot of files.

In total I needed days until I had collected everything....

Nowadaysif necessary I only copy these folders from one computer to the next and it works. So it looks like the Android SDK Manager does no real "installation" but only a dowloading".


Arabia(Posted 2013) [#11]
Got Android SDK Installed, downloaded and installed Android 4.2.2 (API17) as well as Google USB Driver - that's all I've installed from it so far.

Installed Apache Ant 1.9.2 as well as the Java SDK 1.7.0_25. I've edited the config.winnt.txt file.

So back into Jungle IDE (using the demo version) and after choosing "refresh available targets" from the Monkey menu, all is fine and Android now shows up as a target.

However, when I build a simple program that I found in one of the tutorials:

Import mojo

Function Main()
	New Game
End

Class Game Extends App

	Field player:Image
	Field x:Float
	Field y:Float
	
	Method OnCreate()
		player = LoadImage ("boing.png")
		SetUpdateRate 60
	End
	
	Method OnUpdate()
		If KeyDown(KEY_LEFT) Then x = x - 4
		If KeyDown(KEY_RIGHT) Then x = x + 4
		If KeyDown(KEY_UP) Then y = y - 4
		If KeyDown(KEY_DOWN) Then y = y + 4
	End
	
	Method OnRender()
		Cls 64, 96, 128
		DrawImage player, x, y 
	End
End


This works if built for HTML5, but if I choose Android as my target I get an error message when building:

'adb' is not recognized as an internal or external command,
operable program or batch file.
TRANS FAILED: TRANS Failed to execute 'adb start-server', return code=1
Abnormal program termination. Exit code: -1[


Any ideas what I'm doing wrong?


Arabia(Posted 2013) [#12]
Sorry, ignore my last question - I had the path for the Android SDK incorrect, fixed that and it now builds - but still get's stuck. Here is where I'm at:

C:\monkeypro\MonkeyPro63b\bin\trans_winnt.exe -run -config=debug -target=android   "C:\Users\John\Desktop\Monkey Games\First Game\firstgame.monkey"
TRANS monkey compiler V1.39
Parsing...
Semanting...
Translating...
Building...
Buildfile: C:\Users\John\Desktop\Monkey Games\First Game\firstgame.build\android\build.xml

-check-env:
 [checkenv] Android SDK Tools Revision 22.0.5
 [checkenv] Installed at C:\android_sdk\win_x86\sdk

-setup:
     [echo] Project Name: MonkeyGame
  [gettype] Project Type: Application

-pre-clean:

clean:
[getlibpath] Library dependencies:
[getlibpath] No Libraries
   [subant] No sub-builds to iterate on

BUILD SUCCESSFUL
Total time: 3 seconds
Buildfile: C:\Users\John\Desktop\Monkey Games\First Game\firstgame.build\android\build.xml

-set-mode-check:

-set-debug-files:

-check-env:
 [checkenv] Android SDK Tools Revision 22.0.5
 [checkenv] Installed at C:\android_sdk\win_x86\sdk

-setup:
     [echo] Project Name: MonkeyGame
  [gettype] Project Type: Application

-set-debug-mode:

-debug-obfuscation-check:

-pre-build:

-build-setup:
[getbuildtools] Using latest Build Tools: 18.0.1
     [echo] Resolving Build Target for MonkeyGame...

BUILD FAILED
C:\android_sdk\win_x86\sdk\tools\ant\build.xml:543: Unable to resolve project target 'android-13'

Total time: 1 second
TRANS FAILED: Android build failed.
Abnormal program termination. Exit code: -1


What does Unable to resolve project target 'android-13' mean?


Arabia(Posted 2013) [#13]
Slowly getting there, sorry to keep posting, but hopefully when I do find answers they may help someone else out.

Seems that I should have installed the Android 3.2 (API13) SDK - done that, and now I'm getting a lot further though the compiling process, but it falls over at the end with:

install:
     [echo] Installing C:\Users\John\Desktop\Monkey Games\First Game\firstgame.build\android\bin\MonkeyGame-debug.apk onto default emulator or device...
     [exec] Error: Could not access the Package Manager.  Is the system running?
     [exec] 759 KB/s (59869 bytes in 0.077s)

BUILD SUCCESSFUL
Total time: 11 seconds
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
Error type 2

android.util.AndroidException: Can't connect to activity manager; is the system running?

Process ended with return code 0 at 8/8/2013 4:03:58 PM


I've got my Samsung Galaxy 3 plugged in (not sure if that's needed) and have also started an AVD from the Android SDK (not sure if I should be doing that either)

EDIT: Manually copied the files over from the .build/android directory for my test game onto the Tablet, and then ran the MonkeyGame-debug.apk and got it going :)

But I assume there is a way to get it going in the AVD emulator that I'm missing?


Midimaster(Posted 2013) [#14]
Gratulation! You got it work...

I would suggest not to use the AVD emulator: It is too slow.

The best way is to build directly to the smartphone. For me it looks like the USB connection is not working perfect...

Some checks:

How did you copy the APK file from the computer to the smartphone? If it was via USB the connection seems to work. If not, install Samsung KIES. It is terrible, but brings the correct USB driver.

Did you allow the "unknow sources" feature on the smartphone? If not: Settings - Appliation - Unknows sources".


After you installed now SDK13, you can use it. But you can also config monkey to use SDK 17. Open inside your Monkey directory this subfolder:

...\targets\android\templates\android.manifest

change this content...
	<uses-sdk 
		android:minSdkVersion="3"
		android:targetSdkVersion="7" />

...to...
	<uses-sdk 
		android:minSdkVersion="3"
		android:targetSdkVersion="17" />



Arabia(Posted 2013) [#15]

How did you copy the APK file from the computer to the smartphone? If it was via USB the connection seems to work. If not, install Samsung KIES. It is terrible, but brings the correct USB driver.

Did you allow the "unknow sources" feature on the smartphone? If not: Settings - Appliation - Unknows sources".



Just copy & pasted the files via USB. I do have KIES on my computer from back when I unsuccessfully tried to get my Samsung Phone to transfer files, but haven't used it since.

Yes, I worked out how to turn on "unknown sources"

So currently I'm saving my program on the desktop, building it, then copying files using Windows - if I have my Tablet hooked up via USB, then I should in theory be able to save everything (source code etc. on the tablet as I work) then the build would go straight onto the tablet - is that the correct way to be doing it?


After you installed now SDK13, you can use it. But you can also config monkey to use SDK 17. Open inside your Monkey directory this subfolder:



Ah, was going to ask about that. I'll stick with SDK13 for the moment, just about finished my first game - Naughts & Crosses, hoping to release this onto the Android marketplace and make a million bucks :)


Midimaster(Posted 2013) [#16]
You did everything right! If USB copying is possible the USB driver is installed correct.

There is no need to copy the source codes to the tablet. Only one file...

MonkeyGame-debug.apk

...is necessary. Create a project folder "MyApp" and save the source code "MyApp.monkey" in it. Then move the "MyApp.data" folder too in it. When you now build the app, you will find a "MyApp.build" folder in "MyApp". And inside there is a "android/bin" subfolder. Inside you will find the "MonkeyGame-debug.apk". Copy only this file to your tablet.

I also sometimes have problems with the direct USB connection between Monkey and tablet. In this cases I have to disconnect the tablet. Restart windows and the tablet too. Connect both again, try again. Did you install the USB driver from KIES or from Google? KIES is super terrible. I never use it, but its USB driver seem to work better.


Arabia(Posted 2013) [#17]
Cheers, I'll give that a go tomorrow. For now, I've just copied the whole "Android" folder across which I thought was copying more than needed, but it got it working - I was actually going to ask what was the minimum I needed to copy over and you've answer that for me :)

I've got a couple of other questions to ask, but they are rather long winded, so I'll probably ask tomorrow night - just about to head to bed now.

I still have a hell of a lot to learn about using a tablet let alone programming for one, but I'm more than happy at where I'm at after 24 hours of starting.

Thanks for all the help, as with the Blitz forum, an answer is never far away with Monkey, fantastic to have a helpful community.


Paul - Taiphoz(Posted 2013) [#18]
What to do is get DropBox.com on your PC, it's a could storage service and it's just about the coolest thing ever :) im a big fan in case you didn't realize.

With Drop box anything inside gets synced across all your devices, for your phone download and install the dropbox app, then anything in your dropbox folder will automatically sync over to your phone.

So when I need to test something on my phone, but my usb cable is not hand, I just goto game.build/android/bin/game-debug.apk folder from the dropbox app, i click the apk file and it installs.

I actually have a test folder that I share with all my family and some friends and they test my stuff via this method.

Check it out here http://db.tt/MobVyhmT


trainer(Posted 2013) [#19]
Hello guys
could u plz make a small video or show some pic to describe all of that..
I'm not getting which files shall I modified and how to connect SDK with monkey !! :\
I'm sorry, this is the first time for me in android world, so I will be grateful for ur precious help..:)

Thank u


Raph(Posted 2013) [#20]
You should check that USB debugging is enabled on your device. See here: http://www.monkeycoder.co.nz/Community/posts.php?topic=4009


Gerry Quinn(Posted 2013) [#21]
I don't remember the SDK being that big. Bear in mind you only need a selection of the various Android APIs, not every single one.


Arabia(Posted 2013) [#22]
Hello guys
could u plz make a small video or show some pic to describe all of that..
I'm not getting which files shall I modified and how to connect SDK with monkey !! :\
I'm sorry, this is the first time for me in android world, so I will be grateful for ur precious help..:)

Thank u



What have you downloaded and installed so far? Everything described above?

Have you (assuming you're using Windows) modified your config.winnt.txt file which is in the BIN directory where Monkey is installed?

Here is my config.winnt.txt file with the changes I made (it will be different for you depending on where you install everything) marked as : <--- *****

'--------------------
'HTML player path.
'
'Must be set for HTML5 target support.
'
'for opening .html files...
'
HTML_PLAYER="${TRANSDIR}\mserver_winnt.exe"
'--------------------

'--------------------
'Ant build tool path
'
'Must be set to a valid dir for ANDROID target support
'
'Ant is currently available here: 
'	http://ant.apache.org/bindownload.cgi
'
[b]ANT_PATH="${SYSTEMDRIVE}\ant\apache-ant-1.9.2" <--- *****
ANT_PATH="${SYSTEMDRIVE}\ant"
'--------------------

'--------------------
'MinGW path.
'
'Must be set to a valid dir for STDCPP target support.
'
'MinGW is currently available here:
'	http://tdm-gcc.tdragon.net/download
'
MINGW_PATH="${SYSTEMDRIVE}\MinGW32"
MINGW_PATH="${SYSTEMDRIVE}\MinGW"
'--------------------

'--------------------
'Java dev kit path
'
'Must be set to a valid dir for ANDROID and FLASH target support
'
'Make sure to install the 32 bit JDK, even on 64 bit Windows!
'
'The Java JDK is currently available here:
'	http://www.oracle.com/technetwork/java/javase/downloads/index.html
'
[b]JDK_PATH="${PROGRAMFILES}\Java\jdk1.7.0_25" <--- *****
JDK_PATH="${PROGRAMFILES}\Java\jdk1.7.0_02"
JDK_PATH="${PROGRAMFILES}\Java\jdk1.6.0_23"
JDK_PATH="${PROGRAMFILES}\Java\jdk1.6.0_21"
JDK_PATH="${PROGRAMFILES}\Java\jdk1.6.0_19"
'--------------------

'--------------------
'Android SDK and tool paths.
'
'Must be set to a valid for for ANDROID target support
'
'The Android SDK is currently available here:
'	http://developer.android.com/sdk/index.html
'
[b]ANDROID_PATH="${SYSTEMDRIVE}\android_sdk\win_x86\sdk" <--- *****
'--------------------

'--------------------
'Flex SDK and flash player path.
'
'FLEX_PATH Must be set for FLASH target support.
'
'Either HTML_PLAYER or FLASH_PLAYER must be set for FLASH target support.
'
'The Flex SDK is currently available here:
'	http://opensource.adobe.com/wiki/display/flexsdk/Flex+SDK
'
FLEX_PATH="${SYSTEMDRIVE}\flex_sdk_4.6"
FLEX_PATH="${SYSTEMDRIVE}\flex_sdk_4.5"
FLEX_PATH="${SYSTEMDRIVE}\flex_sdk_4.1.0.16076"
FLEX_PATH="${SYSTEMDRIVE}\flex_sdk_4.1"
FLEX_PATH="${SYSTEMDRIVE}\flex_sdk_4.0.0.14159"
FLEX_PATH="${SYSTEMDRIVE}\flex_sdk_4.0"
FLEX_PATH="${SYSTEMDRIVE}\flex_sdk_4"
FLEX_PATH="${SYSTEMDRIVE}\flex_sdk"
'
'for opening .swf files...monkey will use HTML_PLAYER if this is not set.
'FLASH_PLAYER="${SYSTEMDRIVE}\flex_sdk_4.0\flashplayer_10_sa_debug.exe"
'
'--------------------

'--------------------
'Play Station Suite SDK path.
'
'PSS_PATH must be set for PSS target support.
'
'Note: This will soon be replaced by the Play Station Mobile target - use that instead!
'
PSS_PATH="${PROGRAMFILES}\SCE\Pss"

'--------------------
'Play Station Mobile SDK path.
'
'PSM_PATH must be set for PSM target support.
'
'Note: This will soon replace the Play Station Suite target - use this instead!!!!!
'
PSM_PATH="${PROGRAMFILES}\SCE\PSM"

'--------------------
'MSBUILD path.
'
'Must be set for XNA and GLFW target support.
'
'Visual C++ 2010 Express is required for GLFW target support and is currently available here:
'	http://www.microsoft.com/visualstudio/en-us/products/2010-editions/visual-cpp-express
'
'Visual C# 2010 Express and XNA 4.0 are requred for XNA target support and are currently available here:
'	http://www.microsoft.com/visualstudio/en-us/products/2010-editions/visual-csharp-express
'	http://www.microsoft.com/download/en/details.aspx?id=23714
'
MSBUILD_PATH="${WINDIR}\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe"
'--------------------



trainer(Posted 2013) [#23]
I just downloaded all of these in the pic :P




and this is my change at "config.winnt.txt" I just followed ur instructions



Am I moving in a right way ??

Why android target not showing up to me at monkey till now ?? :(


Volker(Posted 2013) [#24]
The android path should be:
ANDROID_PATH="${SYSTEMDRIVE}\Users\toshiba\Desktop\Android",
so the "\C:\" must be removed.


trainer(Posted 2013) [#25]
Hello :)
I did it, I found the issue .. it was with the path ><

This subject here was very helpful
http://www.monkeycoder.co.nz/Community/posts.php?topic=636

But it seems like I have another problem here,,
I will post it if I got stuck at it


Thank u guys.. U r amazing <3


trainer(Posted 2013) [#26]
Hi ..
This is the change I made, and it worked well by following ur other instructions



Thanks ^_^


SLotman(Posted 2013) [#27]
And a tip for you guys: install BlueStacks emulator. Will run things much faster than that awful android emulator that comes with the sdk!


computercoder(Posted 2013) [#28]
Hey thanks for that tip, SLotman :) I had no idea there was anything but the slow ones that come with the SDK :) I've just been using my droid devices as test beds, and then hope for the best on the rest :P


Volker(Posted 2013) [#29]
For me, if installing BlueStacks, Monkey does not deploy to my phone.
Throws a "more than one device found" error.
Have to kill the BlueStacks services via task manager.