Tutorial: Compiling an Android Module for Godot
Autor: Shin-NiL | Publicado: 2016-03-07T21:49:00-03:00






This tutorial is outdated, for Godot 2.1 (or above) please refer the official documentation, it's much better now. 


This is a step by step tutorial explaining how to compile a custom android module for Godot 2.0. For that, we'll be using the appodeal module, but you can easily adapt it for any other.

NOTICE: As related by our friend Joaquim on the comments (and confirmed by myself), building the android template on Windows is problematic, so I strongly recommend the use of Linux for this task. 

Step 1 - Installing the prerequisites
Install the following tools: 

Python 2.7 
Scons
Git
Android NDK
Android SDK (19) 

Android SDK Build-tools (19.1)
Android Support Repository
Google Play services
Google Repository



Step 2 - Setting some environment&nbsp; variables

Set the environment variable ANDROID_HOME to point to the root of your Android SDK installation;&nbsp;
Set the environment variable ANDROID_NDK_ROOT to point to the root of your Android NDK installation. 


Step 3 - Cloning and checking out Godot 2.0
You'll need the Godot source code, you can get it using the following git commands 
git clone https://github.com/godotengine/godot.git
git checkout 2.0-stable


Step 4 - Copying your module files

Download the GodotAppodeal repository (branch GodotAppodeal-2.0) files as a zip. Note: as I said before, this can be changed for any other module of your wish;
extract the file above and move the appodeal folder and its contents to 'yourGodotSourceCodeFolder/modules';



Step 5 - Compiling the Godot lib
On the root of the Godot engine folder type:
scons platform=android target=release_debug
or
scons platform=android target=release
If everything goes fine, you should get a .so file inside the 'yourGodotSourceCodeFolder/bin/', something like 'libgodot.android.opt.debug.armv7.neon.so'. 



Step 6 - Copying the Godot lib

Create the folder 'yourGodotSourceCodeFolder/platform/android/java/libs/armeabi';
copy the .so output file from step 5 to the new folder and rename it to 'libgodot_android.so'



Step 7 - Building the APK

Go to yourGodotSourceCodeFolder/platform/android/java;
from command line, run:

gradlew.bat build (Windows)
./gradlew build (Linux)&nbsp;




Step 8 - Getting your reward
After this long journey, the resulting apk should be in&nbsp; 'yourGodotSourceCodeFolder/platform/android/java/build/outputs/apk'. 


Sanity Tip:
To make sure your environment setup is fine, you can skip step 4 for the first time. This way you'll compile a bare Godot Android template wihout any third party module.

Was this post useful for you?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