Changes between Version 241 and Version 242 of AndroidPort


Ignore:
Timestamp:
Jan 9, 2015, 7:55:13 PM (9 years ago)
Author:
BogDan
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • AndroidPort

    v241 v242  
    111111 * ''libxml2'' - Compiles natively against the NDK if iconv bindings are disabled.
    112112 * ''OpenGL'' - This must be ported to OpenGL ES.
    113  * ''OpenAL'' - This should be ported to OpenSL ES.
     113 * ''OpenAL'' - Compiles natively against the NDK.
    114114 * ''zip'' - Not sure which exact library this refers to?
    115115 * ''libogg'' - May be covered by Tremor (below).
     
    140140$ mkdir ~/android
    141141}}}
    142 Next, [http://developer.android.com/sdk/installing.html install the Android SDK]. Download the SDK package from [http://developer.android.com/sdk/index.html this page] to the working directory and then unpack it there, e.g.:
     142Next, [http://developer.android.com/sdk/installing.html install the Android SDK]. Download the SDK package from [http://developer.android.com/sdk/index.html#Other this page] to the working directory and then unpack it there, e.g.:
    143143
    144144{{{
    145145$ cd ~/android
    146 $ tar -xvf android-sdk_r22.2.1-linux.tgz
     146$ tar -xvf android-sdk_r24.0.2-linux.tgz
    147147}}}
    148148Now complete the installation by running the `android` tool:
     
    151151$ ~/android/android-sdk-linux/tools/android
    152152}}}
    153 A window with installable packages should open. In addition to any packages checked by default, make sure 'Android SDK Platform-tools' is checked and click 'Install packages'.
    154 
    155 Google publishes a [http://developer.android.com/sdk/ndk/index.html Native Development Kit] (NDK), which is a set of tools for building native applications for the Android platform. Unfortunately, the official NDK does not and will not support the `std::wstring` (wide characters) datatype, which is required by the game, so we'll have to use the unofficial [http://www.crystax.net/android/ndk.php Crystax NDK]. This is merely an extension of the official NDK, adding support for wide characters and other features maligned by Google.
    156 
    157 Download the r8-crystax-1 NDK release from [http://www.crystax.net/en/android/ndk this page] to the working directory and then unpack there, e.g.:
     153A window with installable packages should open. In addition to any packages checked by default, make sure '''Android SDK Platform-tools''', and '''Android 4.4.2 (API 19) -> SDK Platform''' are checked and click 'Install packages'. '''Android 4.4.2 (API 19) -> SDK Platform''' is needed only to build the APK, the game will still run on lower API (it needs API-12 or higher).
     154
     155~~Google publishes a [http://developer.android.com/sdk/ndk/index.html Native Development Kit] (NDK), which is a set of tools for building native applications for the Android platform. Unfortunately, the official NDK does not and will not support the `std::wstring` (wide characters) datatype, which is required by the game, so we'll have to use the unofficial [http://www.crystax.net/android/ndk.php Crystax NDK]. This is merely an extension of the official NDK, adding support for wide characters and other features maligned by Google.~~
     156
     157~~Download the r8-crystax-1 NDK release from [http://www.crystax.net/en/android/ndk this page] to the working directory and then unpack there, e.g.:~~
     158
     159Download the [http://developer.android.com/sdk/ndk/index.html official NDK].
    158160{{{
    159161$ cd ~/android
    160 $ tar -xvf android-ndk-r8-crystax-1-linux-x86_64.tar.bz2
    161 }}}
     162$ chmod +x android-ndk-r10d-linux-x86_64.bin
     163$ ./android-ndk-r10d-linux-x86_64.bin
     164}}}
     165
     166By default the script that will download & build all Pyrogenesis' dependencies will search for Android SDK & Android NDK in the following locations:
     167{{{
     168~/android/android-ndk
     169~/android/android-sdk
     170}}}
     171If you don't want to pass their location manually, then you have to rename them.
     172
    162173
    163174You also must install a Java Development Kit (JDK) if you haven't already, e.g. [https://apps.ubuntu.com/cat/applications/oneiric/default-jdk/ the standard JDK from Ubuntu Software Center]:
     
    166177}}}
    167178
    168 Make sure [http://ant.apache.org/ Ant], [http://subversion.tigris.org/ Subversion] and [http://www.gnu.org/software/autoconf/ autoconf] 2.13 is installed:
    169 {{{
    170 $ sudo apt-get install ant subversion autoconf2.13
     179Make sure [http://ant.apache.org/ Ant], [http://subversion.tigris.org/ Subversion] and [http://www.gnu.org/software/autoconf/ autoconf] 2.13 , wget and git is installed:
     180{{{
     181$ sudo apt-get install ant subversion autoconf2.13 wget git
    171182}}}
    172183
     
    176187}}}
    177188
    178 Finally, download the game sources from SVN to any location, e.g.:
    179 {{{
    180 $ svn co http://svn.wildfiregames.com/public/ps/trunk/ ~/android/0ad-game
    181 }}}
     189Download and install [http://www.qt.io/download-open-source Qt SDK] '''for Android'''. Pyrogenesis doesn't depend on Qt, it needs it just to build the engine and create APK. You'll use !QtCreator to manage, build, '''run & debug on Android'' Pyrogenesis. If you are not used with !QtCreator, [http://www.kdab.com/qtcreator here] you can find its reference card.
     190
     191Finally, download the game sources from '''a temporary github location''' to any location, e.g.:
     192{{{
     193$ git clone https://github.com/bog-dan-ro/0ad.git
     194}}}
     195
     196
     197~~Finally, download the game sources from SVN to any location, e.g.:~~
     198~~$ svn co http://svn.wildfiregames.com/public/ps/trunk/ ~/android/0ad-game~~
    182199
    183200=== Compiling dependencies and game ===
    184201
    185 (These instructions are pretty imprecise, but in practice it's possible to get them to work with at least some versions of the game.)
    186 
    187 First download SDL 2.0:
    188 {{{
    189 cd build/android/sdl-project/jni/
    190 wget http://www.libsdl.org/release/SDL2-2.0.1.tar.gz
    191 tar xvf SDL2-2.0.1.tar.gz
    192 mv SDL2-2.0.1 SDL
    193 }}}
    194 
    195 Then build SDL and the .apk (the installable application that invokes the external game engine code):
    196 {{{
    197 cd build/android/sdl-project/
    198 make
    199 }}}
    200 (Dependency checking is probably broken, so run "`make clean`" if you need to rebuild after changing stuff.)
    201 
    202 Then install all the dependencies:
     202Build & install all the dependencies:
    203203{{{
    204204cd build/android/
    205205./setup-libs.sh
    206206}}}
    207 The script hardcodes the expected locations of NDK and SDK, so put them there or adjust the script, and it will output to `~/android/toolchain-0ad`. That should download and compile loads of stuff.
    208 
    209 Build the game like:
    210 {{{
    211 cd build/workspaces/
    212 ./update-workspaces.sh --gles --android --without-audio --disable-atlas --with-system-mozjs185 --with-system-enet --with-system-nvtt --without-nvtt
    213 
    214 cd gcc/
    215 TOOLCHAIN=${HOME}/android/toolchain-0ad PKG_CONFIG_LIBDIR=${TOOLCHAIN}/sysroot/usr/local/lib/pkgconfig LDFLAGS="-lSDL2 -L=/usr/local/lib -L../../android/sdl-project/libs/armeabi" INCLUDES="--sysroot=${TOOLCHAIN}/sysroot -I${TOOLCHAIN}/arm-linux-androideabi/include/c++/4.6/arm-linux-androideabi/armv7-a/ -I../../android/sdl-project/jni/SDL/include -isystem=/usr/local/include/boost-1_45" CXX=${TOOLCHAIN}/bin/arm-linux-androideabi-g++ make pyrogenesis -j3 config=debug
    216 }}}
    217 
    218 Then attach a device, and in `build/android/sdl-project/` run "`make push-apk`" and "`make push-so`". Run `/sdcard/0ad.apk` on the device to install.
    219 
    220 The .apk is basically just the standard SDL android-project, and it loads `/data/local/libpyrogenesis_dbg.so` which contains all the engine code. That means you can recompile and then upload the engine code (via "`make push-so`") on the host PC, and don't have to manually reinstall the app after each change. If you want a non-debug build, remove the "`config=debug`" when building the game, then copy `binaries/system/libpyrogenesis.so` to `libpyrogenesis_dbg.so` before running "`make push-so`".
    221 
    222 You need to use the game engine to create `public.zip` for data files, since it has to convert all the textures/models/animations/etc into a different format before zipping them up. Build a standard non-Android copy of the game, then run it like
    223 {{{
    224 mkdir temp
    225 binaries/system/pyrogenesis -archivebuild=binaries/data/mods/public -archivebuild-output=temp/public.zip -archivebuild-compress
    226 }}}
    227 and it should print lots of output and will take a while (maybe ten minutes or more). Then copy to `/sdcard/0ad/data/mods/public/public.zip` and the game should see it. (If you want to change a few data files after that, you don't need to regenerate `public.zip` - just copy the individual files straight into `mods/public/` and they'll override the zipped version.)
    228 
    229 Also, copy `binaries/data/config/default.cfg` into `/sdcard/0ad/appdata/config/`, and optionally set any local configuration values in `/sdcard/0ad/appdata/config/local.cfg`.
    230 
    231 Then try running the game, and use "`adb logcat`" to see what fails, and fix it.
     207The script searches for NDK in '''~/android/android-ndk''' if you have it in another location then use '''-n''' parameter to pass its location. The script should run without problems. If fails and you can't fix it, please contact us, otherwise you'll not be able to compile Pyrogenesis.
     208
     209Next step is to setup !QtCreator for Android. [http://www.kdab.com/qt-on-android-episode-2/ This article] explains you how to do it.
     210After you've finished to setup !QtCreator for Android, then you can open the project from `0ad/build/android/qtcreator/qtceator.pro`. After you open the project, make sure you choose an '''Android KIT''', check first part of [http://www.kdab.com/qt-android-episode-3/ this article] for more information.
     211
     212Do not try to start the game if you didn't push the game data (check the next step).
     213
     214~~Build the game like:~~
     215~~cd build/workspaces/~~
     216~~./update-workspaces.sh --gles --android --without-audio --disable-atlas --with-system-mozjs185 --with-system-enet --with-system-nvtt --without-nvtt~~
     217
     218~~cd gcc/~~
     219~~TOOLCHAIN=${HOME}/android/toolchain-0ad PKG_CONFIG_LIBDIR=${TOOLCHAIN}/sysroot/usr/local/lib/pkgconfig LDFLAGS="-lSDL2 -L=/usr/local/lib -L../../android/sdl-project/libs/armeabi" INCLUDES="--sysroot=${TOOLCHAIN}/sysroot -I${TOOLCHAIN}/arm-linux-androideabi/include/c++/4.6/arm-linux-androideabi/armv7-a/ -I../../android/sdl-project/jni/SDL/include -isystem=/usr/local/include/boost-1_45" CXX=${TOOLCHAIN}/bin/arm-linux-androideabi-g++ make pyrogenesis -j3 config=debug~~
     220
     221~~Then attach a device, and in `build/android/sdl-project/` run "`make push-apk`" and "`make push-so`". Run `/sdcard/0ad.apk` on the device to install.~~
     222
     223~~The .apk is basically just the standard SDL android-project, and it loads `/data/local/libpyrogenesis_dbg.so` which contains all the engine code. That means you can recompile and then upload the engine code (via "`make push-so`") on the host PC, and don't have to manually reinstall the app after each change. If you want a non-debug build, remove the "`config=debug`" when building the game, then copy `binaries/system/libpyrogenesis.so` to `libpyrogenesis_dbg.so` before running "`make push-so`".~~
     224
     225You need to use the game engine to create `public.zip` and `mod.zip` for data files, since it has to convert all the textures/models/animations/etc into a different format before zipping them up. Build a standard non-Android copy of the game, then run it like
     226{{{
     227$ mkdir temp
     228$ binaries/system/pyrogenesis -archivebuild=binaries/data/mods/public -archivebuild-output=temp/public.zip -archivebuild-compress
     229$ binaries/system/pyrogenesis -archivebuild=binaries/data/mods/mod -archivebuild-output=temp/mod.zip -archivebuild-compress
     230}}}
     231and it should print lots of output and will take a while (maybe ten minutes or more).
     232
     233Then copy them to your device:
     234{{{
     235$ adb push temp/public.zip /sdcard/0ad/data/mods/public/public.zip
     236$ adb push temp/mod.zip /sdcard/0ad/data/mods/mod/mod.zip
     237}}}
     238
     239and the game should see it. (If you want to change a few data files after that, you don't need to regenerate `public.zip` - just copy the individual files straight into `mods/public/` and they'll override the zipped version.)
     240
     241Also, copy `binaries/data/config/default.cfg` into `/sdcard/0ad/appdata/config/default.cfg`, and optionally set any local configuration values in `/sdcard/0ad/appdata/config/user.cfg`.
     242{{{
     243$ adb push binaries/data/config/default.cfg /sdcard/0ad/appdata/config/default.cfg
     244}}}
     245
     246Then finally, try running/debugging the game using !QtCreator (press Ctrl+R run, F5 debug).
     247
     248~~~Then try running the game, and use "`adb logcat`" to see what fails, and fix it.~~~