HOW TO: Build Android target

Martin

Active member
CX Code Contributor
3rd Party Module Dev
Tutorial Author
Joined
Jun 19, 2017
Messages
320
Windows

Download and install the Java SDK, take the 32bit one, so the x86 target like jdk-8u131-windows-i586.exe:
http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

Download and install Android Studio:
https://developer.android.com/studio/index.html

In your Cerberus folder, open the file bin/config.winnt.txt and change the following variables:
JDK_PATH - path to your Java SDK installation
ANDROID_PATH - path to your Android SDK installation

That's it. You should now be able to build android apps.

You can make more build adjustments in the targets folder config file: targets/android/template/config.cxs

ANDROID_APP_LABEL - the name of your app
ANDROID_APP_PACKAGE - your bundle identifier, usually: com.yourcompany.appname
ANDROID_SCREEN_ORIENTATION - orientation of your game, either portrait, landscape or user (both)
ANDROID_MIN_SDK_VERSION - the min API level which you want to support. For Admob you need at least 14.
ANDROID_TARGET_SDK_VERSION - the current API level you want to build with. Should be always the latest one (currently 26)
ANDROID_BUILD_TOOLS_VERSION - the build tools version, currently 26.0.0
ANDROID_VERSION_CODE - this is kind of a build number and must always be greater than the last one in case you want to upload your app to Google Play Store
ANDROID_VERSION_NAME - your version number

If you experience this error during compilation

You have not accepted the license agreements

and you have accepted all the licenses when Android Studio asked you to do so...
fixing this can be done by copying the licenses folder located at

C:\Users\YourPcUserName\AppData\Local\Android\sdk

to the folder

C:\Program Files\Android\Android Studio

After that it should compile fine.


Mac OS

Download and install Android Studio:
https://developer.android.com/studio/index.html

In your Cerberus folder, open the file bin/config.macos.txt and change the following variables:
ANDROID_PATH - path to your Android SDK installation

That's it. You should now be able to build android apps.

You can make more build adjustments in the targets folder config file: targets/android/template/config.cxs

ANDROID_APP_LABEL - the name of your app
ANDROID_APP_PACKAGE - your bundle identifier, usually: com.yourcompany.appname
ANDROID_SCREEN_ORIENTATION - orientation of your game, either portrait, landscape or user (both)
ANDROID_MIN_SDK_VERSION - the min API level which you want to support. For Admob you need at least 14.
ANDROID_TARGET_SDK_VERSION - the current API level you want to build with. Should be always the latest one (currently 26)
ANDROID_BUILD_TOOLS_VERSION - the build tools version, currently 26.0.0
ANDROID_VERSION_CODE - this is kind of a build number and must always be greater than the last one in case you want to upload your app to Google Play Store
ANDROID_VERSION_NAME - your version number
 
Last edited by a moderator:

Holzchopf

Moderator
3rd Party Module Dev
Tutorial Author
Joined
Jul 31, 2017
Messages
482
Thanks!

Shouldn't the variable ANDROID_NDK_PATH also be modified in bin/config.winnt.txt? Speaking of which: how is the rest of android sdk supposed to appear on my hard drive? I guess installing Android Studio is the most convenient way ;-) At least that's what I did. To place the tools folder from r25.2.5, I renamed the one that was put there by AS to tools_original before copying the one from the .zip - in case anybody is wondering...

Anyways, this guide helped me getting my first app compiled and running! =)
 

Martin

Active member
CX Code Contributor
3rd Party Module Dev
Tutorial Author
Joined
Jun 19, 2017
Messages
320
Welcome and no you don't need the NDK at the moment. I think for future updates I'm going to add NDK builds as well but for now Android Studio is enough using the latest SDK.

I have to update this guide as ANT isn't needed anymore as Cerberus uses Gradle now.
 

Martin

Active member
CX Code Contributor
3rd Party Module Dev
Tutorial Author
Joined
Jun 19, 2017
Messages
320
Adapted to the current situation with Gradle builds.
 

Martin

Active member
CX Code Contributor
3rd Party Module Dev
Tutorial Author
Joined
Jun 19, 2017
Messages
320
LiWHAT? :D Oh wait just kidding. Should be the same as for MacOS which is basically just a NIX system.
 

dawlane

Well-known member
CX Code Contributor
Joined
Jun 21, 2017
Messages
795
How does someone go on Linux?
The hardest part is choosing whether or not to use OpenJDK or go through the hassle of of installing the Oracle JDK.

EDIT:
OpenJDK is the easiest with it being in the repositories and seems to work correctly, but is not always in sync with the Oracle version.

Ubuntu and derivatives can use the PPA from WEB UPD8. But you are relying on the trust worthiness of a third party.

You can install the tar.gz version localy and set and add the JAVA_HOME and PATH environment variables in the .bashrc file to point to the necessary locations where the JDK is unpacked.

You can find a few useful scripts and other pointers in monkey-linux-install-manual.tar.gz
 
Last edited:

Martin

Active member
CX Code Contributor
3rd Party Module Dev
Tutorial Author
Joined
Jun 19, 2017
Messages
320
I see, thanks dawlane!
 

Dubbsta

New member
Joined
Jul 13, 2017
Messages
186
hi, need help with android compile also

"D:/Program Files (x86)/Cerberus/bin/transcc_winnt" -target=Desktop_Game_(Glfw3) -config=Release "D:/Program Files (x86)/Cerberus/spacegame/spacegame.monkey"

TRANS cerberus compiler V2017-10-24

Parsing...

Semanting...

Translating...

Building...

g++ -m64 -O3 -DNDEBUG -Wno-free-nonheap-object -I../curl/include -I../glfw3/include -I../glfw3/src -I../openal/include -I../stb -I../zlib-1.2.8 -I../lpng1610 -c -o build/Release64/main.o ../main.cpp

g++ -m64 -s -LD:/Program Files (x86)/Cerberus/libs/Win64 -Wl,--subsystem,windows -o Release64/CerberusGame build/Release64/context.o build/Release64/egl_context.o build/Release64/init.o build/Release64/input.o build/Release64/monitor.o build/Release64/osmesa_context.o build/Release64/vulkan.o build/Release64/wgl_context.o build/Release64/win32_init.o build/Release64/win32_joystick.o build/Release64/win32_monitor.o build/Release64/win32_time.o build/Release64/win32_thread.o build/Release64/win32_window.o build/Release64/window.o build/Release64/stb_vorbis.o build/Release64/stb_image.o build/Release64/main.o -lcomdlg32 -lgdi32 -lopengl32 -lopenal32 -lws2_32

g++: error: Files: No such file or directory

g++: error: (x86)/Cerberus/libs/Win64: No such file or directory

Makefile:53: recipe for target 'Release64/CerberusGame' failed

mingw32-make: *** [Release64/CerberusGame] Error 1

TRANS FAILED: Error executing 'mingw32-make CCOPTS=" -m64 -O3 -DNDEBUG" LDOPTS=" -m64 -s -LD:/Program Files (x86)/Cerberus/libs/Win64" LIBOPTS=" -lopenal32" OUT="Release64/CerberusGame"', return code=2

Done.
 

muruba

New member
CX Code Contributor
3rd Party Module Dev
Tutorial Author
Patreon Silver
Joined
Jul 5, 2017
Messages
230
It's not an android build, please double-check
 

Dubbsta

New member
Joined
Jul 13, 2017
Messages
186
thanks muruba that was the win build i need help with too. this is the android. yes mike i installed android studio i can upload my winnt.txt
if needed. it says build successful but cant find it or any apk. this is the log thanks


"D:/Program Files (x86)/Cerberus/bin/transcc_winnt" -target=Android_Game -config=Release "D:/Program Files (x86)/Cerberus/spacegame/spacegame.monkey"

TRANS cerberus compiler V2017-10-24

Parsing...

Semanting...

Translating...

Building...

NDK is missing a "platforms" directory.

If you are using NDK, verify the ndk.dir is set to a valid NDK directory. It is currently set to C:\Users\eric_\AppData\Local\Android\Sdk\ndk-bundle.

If you are not using NDK, unset the NDK variable from ANDROID_NDK_HOME or local.properties to remove this warning.



Incremental java compilation is an incubating feature.

:app:clean

:app:preBuild UP-TO-DATE

:app:preReleaseBuild UP-TO-DATE

:app:checkReleaseManifest

:app:preDebugBuild UP-TO-DATE

:app:prepareComAndroidSupportAnimatedVectorDrawable2600Alpha1Library

:app:prepareComAndroidSupportAppcompatV72600Alpha1Library

:app:prepareComAndroidSupportSupportCompat2600Alpha1Library

:app:prepareComAndroidSupportSupportCoreUi2600Alpha1Library

:app:prepareComAndroidSupportSupportCoreUtils2600Alpha1Library

:app:prepareComAndroidSupportSupportFragment2600Alpha1Library

:app:prepareComAndroidSupportSupportMediaCompat2600Alpha1Library

:app:prepareComAndroidSupportSupportV42600Alpha1Library

:app:prepareComAndroidSupportSupportVectorDrawable2600Alpha1Library

:app:prepareReleaseDependencies

:app:compileReleaseAidl

:app:compileReleaseRenderscript

:app:generateReleaseBuildConfig

:app:generateReleaseResValues

:app:generateReleaseResources

:app:mergeReleaseResources

:app:processReleaseManifest

:app:processReleaseResources

:app:generateReleaseSources

:app:incrementalReleaseJavaCompilationSafeguard

:app:javaPreCompileRelease

:app:compileReleaseJavaWithJavac

:app:compileReleaseJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.).

Note: D:\Program Files (x86)\Cerberus\spacegame\spacegame.buildv2017-10-24\android\app\src\main\java\com\cerberus\cerberusgame\CerberusGame.java uses or overrides a deprecated API.

Note: Recompile with -Xlint:deprecation for details.

Note: D:\Program Files (x86)\Cerberus\spacegame\spacegame.buildv2017-10-24\android\app\src\main\java\com\cerberus\cerberusgame\CerberusGame.java uses unchecked or unsafe operations.

Note: Recompile with -Xlint:unchecked for details.

:app:compileReleaseNdk UP-TO-DATE

:app:compileReleaseSources

:app:lintVitalRelease

:app:mergeReleaseShaders

:app:compileReleaseShaders

:app:generateReleaseAssets

:app:mergeReleaseAssets

:app:transformClassesWithDexForRelease



Running dex as a separate process.



To run dex in process, the Gradle daemon needs a larger heap.

It currently has 1024 MB.

For faster builds, increase the maximum heap size for the Gradle daemon to at least 1536 MB.

To do this set org.gradle.jvmargs=-Xmx1536M in the project gradle.properties.

For more information see https://docs.gradle.org/current/userguide/build_environment.html



:app:mergeReleaseJniLibFolders

:app:transformNativeLibsWithMergeJniLibsForRelease

:app:processReleaseJavaRes UP-TO-DATE

:app:transformResourcesWithMergeJavaResForRelease

:app:validateSigningRelease

:app:packageRelease

:app:assembleRelease



BUILD SUCCESSFUL



Total time: 9.549 secs

Done.
 

Raph

New member
Joined
Aug 25, 2017
Messages
23
Just pinging @ziggy because I was setting up a new laptop with Jungle and Cerberus, and it looks like the auto-install still installs ANT.
 

MikeHart

Administrator
Joined
Jun 19, 2017
Messages
2,815
@Dubbsta it should be located in your porjects directory similar to this:

upload_2017-11-18_9-45-5.png
 

Rob Hewitt

Active member
Tutorial Author
Joined
Aug 30, 2017
Messages
104
I had the same problem originally. Do you think its possible to get Cerberus-X to open a window with this folder open if the build is successful? Might stop this question popping up regularly?
 

Paul Holloway

New member
Joined
Aug 19, 2018
Messages
7
I'm having problems building an app for Android, getting:

FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':app'.
> Failed to install the following SDK components:
platforms;android-27 Android SDK Platform 27
build-tools;27.0.3 Android SDK Build-Tools 27.0.3
The SDK directory is not writable (C:\Program Files\Android\Android Studio)

I have specified Target SDK version 28 and build tools version 28.0.2 in relevant config file, but it still wants to install v27 even though I already installed these as well as 28 using Android Studio. Is there another config file somewhere

Any thoughts?

TIA, Paul H
 

MikeHart

Administrator
Joined
Jun 19, 2017
Messages
2,815
Just go into Android studio and install them from there.
Did you accept the license in Android Studio when you installed 28 and also copied the license folder like I had described above?
 

Paul Holloway

New member
Joined
Aug 19, 2018
Messages
7
Just go into Android studio and install them from there.
Did you accept the license in Android Studio when you installed 28 and also copied the license folder like I had described above?

Thanks for the rapid response.
I have installed from Android Studio, accepted license and copied the licenses folder as described. I specified v28 in config.cxs so I'm puzzled it is still trying to install v27.
 
Top Bottom