instructions for building an android example

This commit is contained in:
frank 2022-10-04 18:33:16 -04:00
parent 1ff7f802cb
commit d0bf52a03d
1 changed files with 81 additions and 18 deletions

View File

@ -23,7 +23,7 @@ Requirements
The repository includes some external libraries in lib/ that the default Makefile included with the demo shows how to compile, but there are other requirements, including external libraries that must be linked to a project in order to compile it.
* libSDL2 (developed against v2.0.14)
* libSDL2 (developed against v2.0.22)
* libSDL2-image
* libSDL2-ttf
* libSDL2-mixer
@ -38,17 +38,17 @@ libSDL2, libSDL2-image, libSDL2-ttf, and libSDL2-mixer must be available to link
### libSDL2
* Download from <http://libsdl.org/download-2.0.php>
* Run ./configure --prefix=[YOUR LIBRARIES PATH] (for example, $HOME/local/sdl)
* Run make && make install
* Run `./configure --prefix=[YOUR LIBRARIES PATH]` (for example, `$HOME/local/sdl`)
* Run `make && make install`
### libSDL2-image, libSDL2-ttf, libSDL2-mixer
* Download from:
* <https://github.com/libsdl-org/SDL_image>
* <https://github.com/libsdl-org/SDL_ttf>
* <https://github.com/libsdl-org/SDL_mixer>
* Run ./configure --prefix=[YOUR LIB PATH] --with-sdl-prefix=[YOUR SDL PATH]
* For example, prefix and SDL prefix can be $HOME/local/sdl
+ https://github.com/libsdl-org/SDL_image
+ https://github.com/libsdl-org/SDL_ttf
+ https://github.com/libsdl-org/SDL_mixer
* Run `./configure --prefix=[YOUR LIB PATH] --with-sdl-prefix=[YOUR SDL PATH]`
* For example, prefix and SDL prefix might be `$HOME/local/sdl`
### OpenGL/GLES/GLES2
@ -75,6 +75,64 @@ Map an image from a rectangle to a circle or from a circle to a rectangle using
An example for using a C++ program to display a webcam stream in the browser using Emscripten to translate the code from C++ to WebAssembly. Get the frame pixel data from a canvas element, read it into a SPACEBOX object, write the pixel data to an OpenGL texture, and use Emscripten to display the video.
Android
-------
See the [SDL wiki Android page][] and the [SDL docs Android README][].
### Building an SDL example from Linux
* Install Java packages
apt install openjdk-17-jdk ant
* Make a folder for Android to store the SDK, NDK, emulator, tools, etc.
mkdir -p ~/local/Android/
* Download [Android command line tools][] to that folder, extract them, and install an NDK (the gradle tool included with SDL seems to be expecting NDK 21.4.7075529). Note that the gradle tool may download Android tools, but this step seems to be necessary for signing the license, which gets created in `licenses`
$ cd ~/local/Android/
$ unzip commandlinetools-linux-8512546_latest.zip
$ cmdline-tools/bin/sdkmanager --sdk_root=$HOME/local/Android/ "ndk;21.4.7075529"
* Download and extract [SDL source][]
$ wget "https://github.com/libsdl-org/SDL/releases/download/release-2.24.0/SDL2-2.24.0.tar.gz"
$ tar -xf SDL2-2.24.0.tar.gz
$ cd SDL2-2.24.0/
* Copy `android-project/` to another folder, symlink the SDL source,
$ cp android-project org.my.testgles
$ cd org.my.testgles/app/jni
$ ln -s ../../.. SDL
* Edit the line with `YourSourcehere.c` in `org.my.testgles/app/jni/src/Android.mk` to point to an SDL example
$ cd src/ && sed -i s#YourSourceHere.c#../SDL/test/testgles.c# Android.mk
* Build with `gradlew` in the root of the project, specifying where to find the Android folder
$ ANDROID_SDK_ROOT=$HOME/local/Android ./gradlew build
* The APK should be output to `app/build/outputs/apk/debug/app-debug.apk`. It can be uploaded to the phone for testing or run on an emulator. To create an emulator, use the Android SDK's tools. For example, to create an Android emulator for API level 31 (Android 12.0) with ABI x86_64.
# Install a version of command line tools with support for later versions of Java
$ cmdline-tools/bin/sdkmanager --sdk_root=$HOME/local/Android "cmdline-tools;latest"
# Install a system image
$ cmdline-tools/bin/sdkmanager --sdk_root=$HOME/local/Android "system-images;android-31;default;x86_64"
# Create emulator
$ cmdline-tools/latest/bin/avdmanager create avd -n android_31_x86_64 -k "system-images;android-31;default;x86_64"
# Launch in the background
$ ~/local/Android/tools/emulator -avd android_31_x86_64 &
# Install the APK to the running emulator
$ ~/local/Android/platform-tools/adb -e install -r app/build/outputs/apk/debug/app-debug.apk
Other libraries
---------------
@ -149,20 +207,25 @@ When initializing a Game object, the framework will attempt to load the font fil
License
-------
SPACEBOX is released under the zlib license. It is free to use, copy, modify and sell. See LICENSE.txt for details.
[SPACEBOX] is released under the zlib license. It is free to use, copy, modify and sell. See LICENSE.txt for details.
Included libraries are included under various permissive licenses compatible with the zlib license:
- BPmono.ttf is licensed under the Creative Commons Attribution - No Derivative Works 3.0 license. See [LICENSE_BPmono.txt][]
- gif-h is unlicensed, public domain code released under the The Unlicense. See [lib/gif-h/LICENSE][]
- GLEW is included under the license in [lib/glew/LICENSE.txt][]
- GLM is included under the MIT license in [lib/glm/LICENSE][]
- nlohmann's json library is included under the MIT license in [lib/json/LICENSE.MIT][]
- SDL2 GFX is included under the license in [lib/sdl2-gfx/LICENSE][]
- superxbr.cpp is included under the license at the top of [lib/superxbr.cpp][]
* BPmono.ttf is licensed under the Creative Commons Attribution * No Derivative Works 3.0 license. See [LICENSE_BPmono.txt]()
* gif-h is unlicensed, public domain code released under the The Unlicense. See [lib/gif-h/LICENSE]()
* GLEW is included under the license in [lib/glew/LICENSE.txt]()
* GLM is included under the MIT license in [lib/glm/LICENSE]()
* nlohmann's json library is included under the MIT license in [lib/json/LICENSE.MIT]()
* SDL2 GFX is included under the license in [lib/sdl2-gfx/LICENSE]()
* superxbr.cpp is included under the license at the top of [lib/superxbr.cpp]()
Contact
-------
- email: frank at shampoo dot ooo
- twitter: https://twitter.com/diskmem
* email: frank at shampoo dot ooo
* twitter: https://twitter.com/diskmem
[SDL wiki Android page]: https://wiki.libsdl.org/Android
[SDL docs Android README]: https://github.com/libsdl-org/SDL/blob/main/docs/README-android.md
[SDL source]: https://github.com/libsdl-org/SDL/releases/
[Android command line tools]: https://developer.android.com/studio#command-tools