- Install Android Studio
- https://developer.android.com/studio/
- TODO: describe how to install NDK packages.
- TODO: describe how to check that NDK 21 is installed.
-
Get SDL sources SDL2-2.0.12.tar.gz and extract to a location of your choice
cd /tmp curl -O https://www.libsdl.org/release/SDL2-2.0.12.tar.gz tar zxvf SDL2-2.0.12.tar.gz
-
Set ANDROID_HOME and ANDROID_NDK_HOME. NDK must have a platform/ directory underneath it to be compatible with SDL's androidbuild.sh
export ANDROID_HOME=$HOME/Android/Sdk export ANDROID_NDK_HOME=$ANDROID_HOME/ndk/21.1.6352462/
-
Run androidbuild.sh script (with COPYSOURCE=1):
COPYSOURCE=1 /tmp/SDL2-2.0.12/build-scripts/androidbuild.sh \ com.orangetide.hellodungeon \ $HOME/my-prototype/src/hellodungeon.c
-
Move project to somewhere suitable:
mv /tmp/SDL2-2.0.12/build/com.orangetide.hellodungeon ~/DEVEL/hellodungeon
-
Move headers so that #include <SDL/SDL.h> works
-
move include/ to include/SDL2 by shuffling it around
cd ~/DEVEL/hellodungeon mv app/jni/SDL/include app/jni/SDL/SDL2 mkdir app/jni/SDL/include mv app/jni/SDL/SDL2 app/jni/SDL/include/
-
Change to
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include/SDL2
vim app/jni/SDL/Android.mk
-
Touch up some of the header files for the new include path
cd ~/DEVEL/hellodungeon sed -i -e 's,../../include,&/SDL2,' $(grep -rl ../include app/jni/SDL/src/events/)
- Move native source to a convenient place
-
Move your source
cd ~/DEVEL/hellodungeon mkdir src mv app/jni/src/*.c src/
-
Edit
LOCAL_SRC_FILES := ../../../src/hellodungeon.c
vim app/jni/src/Android.mk
-
Edit
target_sources(main PRIVATE ../../../src/hellodungeon.c)
vim app/jni/src/CMakeLists.txt
-
Upgrade gradle / Edit to version 7.0.3 or 7.0.2:
cd ~/DEVEL/hellodungeon vim gradle.properties vim gradle/wrapper/gradle-wrapper.properties
-
Fix deprecated gradle features Replace
jcenter()
withmavenCentral()
in both placesvim build.gradle
-
Build from command-line
cd ~/DEVEL/hellodungeon ./gradlew assembleDebug
-
Build from Android studio
- TODO: provide screen shots