Skip to content

Android

JimmySnails edited this page Apr 16, 2020 · 9 revisions

Android Build Instructions

Installing Android Studio

After installing, open up SDK manager and install the following:

Preparing the Android Project

Download the SDL source code (2.0.12) Extract it.

Copy the folder android_project to a seperate location. like D:\android\android_project.

Either create a Symlink from your SDL_Source code dir to app\jni\SDL or create the Folder SDL in app\jni\SDL and copy the content of the source code into it. (we can omit several folders...)

Note: The way, the android projects makefiles are organized, it's important that the folder is called SDL and not otherwise

Since Cytopia uses STL, open app\jniApplication.mk and uncomment as shown:

# Uncomment this if you're using STL in your project
# You can find more information here:
# https://developer.android.com/ndk/guides/cpp-support
APP_STL := c++_shared

CMake vs MakeFiles

It's possible to use either Makefiles or CMakeFiles.

NOTE: But do NOT delete app\jniApplication.mk !

For Cytopia, you can delete the Makefiles and adjust the CMakeFiles accordingly.

Other SDL libraries:

Download the source code for the other SDL libraries and extract them to app\jni Rename each folder and remove the version string from foldername. Like SDL2_ttf-2.0.15 to SDL2_ttf

Open app\jni\src\CMakeLists.txt and uncomment following lines as shown here:

# Compilation of companion libraries
add_subdirectory(SDL_image)
add_subdirectory(SDL_mixer)
add_subdirectory(SDL_ttf)

Source Code

Again, create a symlink or create a folder for the source code in app\jni\src\Cytopia and copy the source code here

Open app\jni\src\CMakeLists.txt and add your source files here: target_sources(main PRIVATE YourSourceHere.c)

Assets

Create a folder assets in *app\src\main*

This folder is for all the assets that'll be used by the game. Copy the content of data/resources to *app\src\main\assets\resources*

Loading the Project

In Android Studio, click on "import project (gradle, eclipse, ...)" and choose your project (e.g. D:\android\android_project)

Click on build