Where to setup the android target ?

BlitzMax Forums/Brucey's Modules/Where to setup the android target ?

Pingus(Posted 2016) [#1]
I get the latest bmx-ng. The build of my simple test runs fine, no error and I get an apk in the end:

Strict
Const WIDTH       = 1024    ' Width of the screen.
Const HEIGHT      = 600     ' Height of the screen.
Const DEPTH       = 32      ' Depth of the screen.
Const REFRESHRATE = 60      ' How often to update the screen (Per second).

Graphics WIDTH,HEIGHT,DEPTH,REFRESHRATE

While KeyHit(key_escape) = False

	DrawText ("Hello guys ! ",200,150)
	Flip()

Wend

EndGraphics()
End



But whatever I change in /bin/custom.bmk I see this in the build strings:


[gettarget] Project Target: Android 6.0
[gettarget] API level: 23



Which may explain why I always get "blitxmax app closed" when I try to run the apk on the device which is android 5.1.

Where can I set up that android version ? I tried miscelaneous platform numbers in custom.bmk but it seems overrided by something else.


Derron(Posted 2016) [#2]
What does
projectDir + "/project.properties"

contain?


Normally it should have some blocks replaced with the things you set in custom.bmk (android.target.sdk).


bye
Ron


RustyKristi(Posted 2016) [#3]
I have not touched android target on NG lately but last time I check, you should set your ndk, sdk path, home, platform and toolchain version according to your device target. Here's my full custom.bmk that works in android 4.2

addoption android.home "C:/Users/home/AppData/Local/Android/android-sdk"
addoption android.sdk C:/Users/home/AppData/Local/Android/android-sdk
addoption android.ndk "C:/android-ndk"
addoption android.toolchain.version "4.8"
addoption android.platform "18"

addoption ant.home "C:/apache-ant"


I got a tip from Brucey last time that you need your bmx app to include SDL2

Framework sdl.gl2sdlmax2d


This is my "helloworld" using NG Android target tested working..

Framework sdl.gl2sdlmax2d
Import brl.pngloader
Import brl.random
Import brl.ramstream
Import brl.standardio


Local Width:Int = DesktopWidth()
Local Height:Int = DesktopHeight()

Graphics Width,Height,0

While Not KeyHit(KEY_ESCAPE) And Not KeyHit(KEY_BROWSER_BACK)
	Cls
	DrawText "Hello World!",10,10
	Flip
Wend

End



Pingus(Posted 2016) [#4]
@Derron,

Yes project.properties include:


target=android-23



But I want to target 22 (android 5.1) or lower.

My bmk is:


addoption android.home "c:/android-sdk"
addoption android.sdk "c:/android-sdk"
addoption android.ndk "c:/android-ndk-r11c"
addoption android.toolchain.version "4.9"
addoption android.platform "19"
addoption ant.home "c:/apache-ant-1.9.6"



There is a mention about


# To customize properties used by the Ant build system edit
# "ant.properties", and override values to adapt the script to your
# project structure.



But I have no idea about the 'syntax' to use.

It seems also that I could edit build.xml from my SDK/ant but it does not seem to affect the platform '23' that I want to override.

Here is the beginning of my compile output (which works fine except that the app does not run).



Building test
Not Found : application settings file 'test.android'. Using defaults...
[ 99%] Processing:test.bmx
[ 99%] Compiling:test.bmx.gui.release.android.armeabi.c
[100%] Linking:test
Buildfile: C:\Blitzmax_bmk4\samples\test\android-project-test\build.xml

-set-mode-check:

-set-debug-files:

-check-env:
[checkenv] Android SDK Tools Revision 25.1.1
[checkenv] Installed at c:\android-sdk

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

-set-debug-mode:

-debug-obfuscation-check:

-pre-build:

-build-setup:
[getbuildtools] Using latest Build Tools: 23.0.3
[echo] Resolving Build Target for test...
[gettarget] Project Target: Android 6.0
[gettarget] API level: 23



I will try Rusty's version in case of but if it builds for Android 6 I guess it will not run on a 5.1 device anyway...


Derron(Posted 2016) [#5]
Building test
Not Found : application settings file 'test.android'. Using defaults...


According to the sources that file "test.android" is based on your application file with Dir and Extension stripped off.

project.bmx
-> project.android


Within this file you could adjust names and so on

test.android
app.package=com.mycompany.appname
app.version.code=1
app.version.name=1.0
app.name=My Game



Regardless of this, "android.sdk" and the likes are read via "GetAndroidSDKTarget()" .... maybe it does not find the SDK at the spot you defined.

target is defined via: "android.sdk.target", if not defined, it tries to find it via the highest number available in "android.sdk" + "/platforms".


Maybe you should add some "prints" to your BMK (compile your own for this) and see where it fails.


bye
Ron


Pingus(Posted 2016) [#6]
Thanks for the hints Ron. Compiling myself bmk always failed (to date) but it gave me a simple idea : I will uninstall Android 6.0 sdk and maybe the compiler will try to stick with the lower version.


Derron(Posted 2016) [#7]
Could you have a look what directories you find within your SDK?

android-SDK/platforms/ ...

In my case this is:
android-7
android-10
android-18
android-19
android-20
android-21
android-23


Your target should exist there...else BMK already falls back to use the highest it could find (so if I target "12", it uses "23").


Could you check that?

Also have a look whether you have set the environment variable "ANDROID_SDK" to another SDK (which might not have the target installed which you want to use).

bye
Ron


Brucey(Posted 2016) [#8]
Android 6 SDK should work fine.

These are the settings in my custom.bmk file :
addoption android.home "/Volumes/programming/Android/android-sdk-macosx"
addoption android.sdk "/Volumes/programming/Android/android-sdk-macosx"
addoption android.ndk "/Volumes/programming/Android/android-ndk-r10c"
addoption android.toolchain.version "4.9"
addoption ant.home "/Volumes/programming/BlitzMax_NG/resources/android/apache-ant"

addoption android.platform "12"
addoption android.sdk.target "23"

Note that "android.platform" is the minimum version of Android your binaries will run on.
"android.sdk.target" is the version of the SDK you want to use to build your stuff. Generally you want to use the latest SDK - which can build apps for older Android versions.
"android.toolchain.version" is the version of the gcc compiler.

In your app folder, next to your app, you should add a <name>.android file.
An example of one I am using for Digesteroids :

digesteroids.android
# application package name for Java class
app.package=net.brucey.android.digesteroids

# application version code
#    An integer value that represents the version of the application code, relative to other versions.
#    You can set the value to any integer you want, however you should make sure that each successive release of your application uses a greater value.
app.version.code=1

# application version name
#    A string value that represents the release version of the application code, as it should be shown to users.
#    The value is a string so that you can describe the application version as a <major>.<minor>.<point> string, or as any other type of absolute or relative version identifier.
app.version.name=1.0

app.name=Digesteroids
app.orientation=landscape

See Android documentation about naming your packages, etc.
The app.name will be the visible name of your app on the screen.


You shouldn't need to mess around with any of those environment variables Derron mentions.
You also shouldn't need to add debug to bmk.

If your app has an error when you try to run it on the device, use the android Monitor app (or whatever is your favourite tool) to look at the stacktrace. Here, it comes out in the log in red.
Usually it tells you what went wrong. If you don't understand the error, post it here, and I can try to help.

If you update to a newer version of bmk, remember to replace the BlitzMax/resources folder with the latest one - as there is android build stuff in there.
Also, you can always try removing the "android-project-<app name>" generated folder and rebuild your app, in case there's stuff in there that isn't refreshing properly.


I just tried a clean build of Digesteroids here to try out the new Bah.Soloud audio module, and it loaded and ran okay. (the display isn't scaled though, as the game design is very basic and doesn't support different resolutions).

I should add, this is on a Nexus 7, running Android 6.
The apk was built for armeabi (armv5) and platform 12, which in theory supports v4+


Brucey(Posted 2016) [#9]
Referring back to the original post :-)

Mobile builds require the SDL modules to drive graphics, events and audio.

For graphics, you can choose to use either sdl.gl2sdlmax2d, for Max2D compatibility, or go with mky.mojo2 (which is a port of Monkey's Mojo2), which isn't Max2D compatible but is a fairly modern shader-based renderer.

For audio, there's sdl.sdlfreeaudio plus the standard audio file loaders. Or you can try bah.soloudaudio which has its own audio file loaders, and also supports streaming. There's also BaH.BASS, in theory, but I haven't spent much time with that on Android yet.

Events are handled through SDL, and should work transparently (i.e. don't worry about it).
There's also a basic touch-based joystick driver in there, which sits on top of the standard joystick stuff, and should work transparently.

Since there are very few experienced Android developers in the community, things are still quite rough around the edges... unfortunately.


Derron(Posted 2016) [#10]
I would suggest to store the post in #8 somewhere within BMK (maybe some "docs"-folder). Just to make things be collected somewhere.


bye
Ron


Pingus(Posted 2016) [#11]
Thanks for the help. ANDOID_SDK is pointing on the good directory (the only one I have with sdk at least). Uninstalling Android 6 indeed builded for the next higher installed android version (22) which is fine.

I don't know why it builds a 'debug' apk, I guess there is no relationship with the 'debug' option of bmk IDE ?

When I build the helloworld sample from Rusti (using therefore sdl.gl2sdlmax2d) the apk at least starts on the device... it does not fail with a error but it simply display a black screen for few seconds then back. I tried a simple code without drawtext (in case of), just displaying a png with same result. It could be my device but I tried also with the emulator (emulated a nexus 7) and it does the same. However, a apk builded with Defold runs fine on my device but not on the emulator. Argh, that emulator is so damned slow !
I have to read more about how to debug...

So I still have a lot to dig to just display a bitmap.


RustyKristi(Posted 2016) [#12]
I have successfully tried it on an actual device which is the most important part but fail to run in any emulator. Of course, it would be a good thing if you can run it on both.


Dabhand(Posted 2016) [#13]
What device is it Pingus?

Dabz


Pingus(Posted 2016) [#14]
A cheap chinese thing : U51GT Talk7x. Bad quality screen but works smoothly (more than my previous Asus).