docs/README-android.md
changeset 13006 4a410f099040
parent 12693 d311fcb8066a
     1.1 --- a/docs/README-android.md	Thu Aug 08 23:35:02 2019 +0300
     1.2 +++ b/docs/README-android.md	Sun Aug 11 15:23:37 2019 +0200
     1.3 @@ -82,6 +82,23 @@
     1.4  
     1.5  4b. If you want to build manually, 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
     1.6  
     1.7 +
     1.8 +If you already have a project that uses CMake, the instructions change somewhat:
     1.9 +
    1.10 +1. Do points 1 and 2 from the instruction above.
    1.11 +2. Edit "<project>/app/build.gradle" to comment out or remove sections containing ndk-build
    1.12 +   and uncomment the cmake sections. Add arguments to the CMake invocation as needed.
    1.13 +3. Edit "<project>/app/jni/CMakeLists.txt" to include your project (it defaults to
    1.14 +   adding the "src" subdirectory). Note that you'll have SDL2, SDL2main and SDL2-static
    1.15 +   as targets in your project, so you should have "target_link_libraries(yourgame SDL2 SDL2main)"
    1.16 +   in your CMakeLists.txt file. Also be aware that you should use add_library() instead of
    1.17 +   add_executable() for the target containing your "main" function.
    1.18 +
    1.19 +If you wish to use Android Studio, you can skip the last step.
    1.20 +
    1.21 +4. Run './gradlew installDebug' or './gradlew installRelease' in the project directory. It will build and install your .apk on any
    1.22 +   connected Android device
    1.23 +
    1.24  Here's an explanation of the files in the Android project, so you can customize them:
    1.25  
    1.26      android-project/app
    1.27 @@ -90,10 +107,12 @@
    1.28          jni/			- directory holding native code
    1.29          jni/Application.mk	- Application JNI settings, including target platform and STL library
    1.30          jni/Android.mk		- Android makefile that can call recursively the Android.mk files in all subdirectories
    1.31 +        jni/CMakeLists.txt	- Top-level CMake project that adds SDL as a subproject
    1.32          jni/SDL/		- (symlink to) directory holding the SDL library files
    1.33          jni/SDL/Android.mk	- Android makefile for creating the SDL shared library
    1.34          jni/src/		- directory holding your C/C++ source
    1.35          jni/src/Android.mk	- Android makefile that you should customize to include your source code and any library references
    1.36 +        jni/src/CMakeLists.txt	- CMake file that you may customize to include your source code and any library references
    1.37          src/main/assets/	- directory holding asset files for your application
    1.38          src/main/res/		- directory holding resources for your application
    1.39          src/main/res/mipmap-*	- directories holding icons for different phone hardware