diff -r 4130b92b6be4 docs/README-android.md --- a/docs/README-android.md Tue Oct 24 00:17:07 2017 -0700 +++ b/docs/README-android.md Tue Oct 24 21:53:16 2017 +0300 @@ -80,6 +80,23 @@ 5. Run './gradlew installDebug' in the project directory. This compiles the .java, creates an .apk with the native code embedded, and installs it on any connected Android device + +If you already have a project that uses CMake, the instructions change somewhat: + +1. Do points 1 and 2 from the instruction above. +2. Edit "/app/build.gradle" to comment out or remove sections containing ndk-build + and uncomment the cmake sections. Add arguments to the CMake invocation as needed. +3. Edit "/app/jni/CMakeLists.txt" to include your project (it defaults to + adding the "src" subdirectory). Note that you'll have SDL2, SDL2main and SDL2-static + as targets in your project, so you should have "target_link_libraries(yourgame SDL2 SDL2main)" + in your CMakeLists.txt file. Also be aware that you should use add_library() instead of + add_executable() for the target containing your "main" function. + +If you wish to use Android Studio, you can skip the last step. + +4. Run './gradlew installDebug' in the project directory. It will build and install your .apk on any + connected Android device + Here's an explanation of the files in the Android project, so you can customize them: android-project/app @@ -89,10 +106,12 @@ jni/ - directory holding native code jni/Application.mk - Application JNI settings, including target platform and STL library jni/Android.mk - Android makefile that can call recursively the Android.mk files in all subdirectories + jni/CMakeLists.txt - Top-level CMake project that adds SDL as a subproject jni/SDL/ - (symlink to) directory holding the SDL library files jni/SDL/Android.mk - Android makefile for creating the SDL shared library jni/src/ - directory holding your C/C++ source jni/src/Android.mk - Android makefile that you should customize to include your source code and any library references + jni/src/CMakeLists.txt - CMake file that you may customize to include your source code and any library references src/main/assets/ - directory holding asset files for your application src/main/res/ - directory holding resources for your application src/main/res/mipmap-* - directories holding icons for different phone hardware