docs/README-android.md
changeset 13006 4a410f099040
parent 12693 d311fcb8066a
equal deleted inserted replaced
13005:ff2e36039fd2 13006:4a410f099040
    80 
    80 
    81 4a. If you want to use Android Studio, simply open your <project> directory and start building.
    81 4a. If you want to use Android Studio, simply open your <project> directory and start building.
    82 
    82 
    83 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
    83 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
    84 
    84 
       
    85 
       
    86 If you already have a project that uses CMake, the instructions change somewhat:
       
    87 
       
    88 1. Do points 1 and 2 from the instruction above.
       
    89 2. Edit "<project>/app/build.gradle" to comment out or remove sections containing ndk-build
       
    90    and uncomment the cmake sections. Add arguments to the CMake invocation as needed.
       
    91 3. Edit "<project>/app/jni/CMakeLists.txt" to include your project (it defaults to
       
    92    adding the "src" subdirectory). Note that you'll have SDL2, SDL2main and SDL2-static
       
    93    as targets in your project, so you should have "target_link_libraries(yourgame SDL2 SDL2main)"
       
    94    in your CMakeLists.txt file. Also be aware that you should use add_library() instead of
       
    95    add_executable() for the target containing your "main" function.
       
    96 
       
    97 If you wish to use Android Studio, you can skip the last step.
       
    98 
       
    99 4. Run './gradlew installDebug' or './gradlew installRelease' in the project directory. It will build and install your .apk on any
       
   100    connected Android device
       
   101 
    85 Here's an explanation of the files in the Android project, so you can customize them:
   102 Here's an explanation of the files in the Android project, so you can customize them:
    86 
   103 
    87     android-project/app
   104     android-project/app
    88         build.gradle            - build info including the application version and SDK
   105         build.gradle            - build info including the application version and SDK
    89         src/main/AndroidManifest.xml	- package manifest. Among others, it contains the class name of the main Activity and the package name of the application.
   106         src/main/AndroidManifest.xml	- package manifest. Among others, it contains the class name of the main Activity and the package name of the application.
    90         jni/			- directory holding native code
   107         jni/			- directory holding native code
    91         jni/Application.mk	- Application JNI settings, including target platform and STL library
   108         jni/Application.mk	- Application JNI settings, including target platform and STL library
    92         jni/Android.mk		- Android makefile that can call recursively the Android.mk files in all subdirectories
   109         jni/Android.mk		- Android makefile that can call recursively the Android.mk files in all subdirectories
       
   110         jni/CMakeLists.txt	- Top-level CMake project that adds SDL as a subproject
    93         jni/SDL/		- (symlink to) directory holding the SDL library files
   111         jni/SDL/		- (symlink to) directory holding the SDL library files
    94         jni/SDL/Android.mk	- Android makefile for creating the SDL shared library
   112         jni/SDL/Android.mk	- Android makefile for creating the SDL shared library
    95         jni/src/		- directory holding your C/C++ source
   113         jni/src/		- directory holding your C/C++ source
    96         jni/src/Android.mk	- Android makefile that you should customize to include your source code and any library references
   114         jni/src/Android.mk	- Android makefile that you should customize to include your source code and any library references
       
   115         jni/src/CMakeLists.txt	- CMake file that you may customize to include your source code and any library references
    97         src/main/assets/	- directory holding asset files for your application
   116         src/main/assets/	- directory holding asset files for your application
    98         src/main/res/		- directory holding resources for your application
   117         src/main/res/		- directory holding resources for your application
    99         src/main/res/mipmap-*	- directories holding icons for different phone hardware
   118         src/main/res/mipmap-*	- directories holding icons for different phone hardware
   100         src/main/res/values/strings.xml	- strings used in your application, including the application name
   119         src/main/res/values/strings.xml	- strings used in your application, including the application name
   101         src/main/java/org/libsdl/app/SDLActivity.java - the Java class handling the initialization and binding to SDL. Be very careful changing this, as the SDL library relies on this implementation. You should instead subclass this for your application.
   120         src/main/java/org/libsdl/app/SDLActivity.java - the Java class handling the initialization and binding to SDL. Be very careful changing this, as the SDL library relies on this implementation. You should instead subclass this for your application.