aboutsummaryrefslogtreecommitdiff
path: root/dists/androidsdl/How_to_Build.txt
blob: c0562ca2ded54f99c8095c0ee29d31ea8f0224cc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
1a) In order to build the androidsdl port you will need a 64-bit Linux OS installation with an Internet connection.
    The following has been tested in lubuntu 64-bit 16.04.6 LTS (xenial), kernel 4.15.0-47-generic.

1b) Make sure you have the latest updates for your OS by running from a shell terminal:
          sudo apt-get update
          sudo apt-get upgrade
    After installing any updates, reboot your PC if required.
    You can also check the Software Updater GUI utility (or similar) for additional pending updates, such as kernel updates or Ubuntu Base updates (for Ubuntu based distributions).
    Reboot your PC, if you are prompted to.

1c) Install the Linux packages that are required for the build:
    Commands:
          sudo apt-get install build-essential
          sudo apt-get install git

1d) Install the JDK. You can do this using the apt-get tool or by downloading the JDK from Oracle's official site (in the latter case you must set environment variables for JDK; see guides "How install JDK and set environment variables for JDK").
    Recommended command:
          sudo apt-get install openjdk-8-jdk

2a) This guide assumes that you create an "~/Android" folder inside your home directory to put the Android SDK and NDK.

2b) Install the Android SDK.

   a) Navigate to url: https://developer.android.com/studio/index.html
      Download the "Command line tools only" packet for Linux ("sdk-tools-linux-4333796.zip" at the time of this writing).
      Create an "~/.android" and an "~/Android" folder in your home directory.
      Then, create a "~/Android/android-sdk" subfolder.
      To do this using a shell terminal issue:
          mkdir ~/.android
          mkdir ~/Android
          mkdir ~/Android/android-sdk

      Unpack the command line tools zip packet inside the "~/Android/android-sdk" folder.
      This should create a "tools" subfolder.

      Install the required android SDK tools.
      Using a shell terminal issue:
          touch ~/.android/repositories.cfg
          cd ~/Android/android-sdk/tools/bin
          ./sdkmanager --install "platforms;android-26"
          ./sdkmanager --install "build-tools;26.0.0"
          ./sdkmanager --install "extras;android;m2repository"

      Accept any license agreement you are prompted with during the above installation process.
      Also, for good measure, issue the following command, then review and accept any pending license agreements:
          ./sdkmanager --licenses

      Then, using the following command verify that you've installed the correct tools:
          ./sdkmanager --list

      You should see a printout that begins like the following:

      Path                          | Version   | Description                     | Location
      -------                       | -------   | -------                         | -------
      build-tools;26.0.0            | 26.0.0    | Android SDK Build-Tools 26.0.0  | build-tools/26.0.0/
      extras;android;m2repository   | 47.0.0    | Android Support Repository      | extras/android/m2repository/
      platforms;android-26          | 2         | Android SDK Platform 26         | platforms/android-26/
      tools                         | 26.1.1    | Android SDK Tools 26.1.1        | tools/

   b) Alternatively, you could download and install the Android Studio for Linux 64-bit. You can then use sdk-manager GUI tool to install the required additional tools and SDK resources. Use the above list as a guide to what packages you should download and install.

3) Install the r15c (July 2017) version for Android NDK ("android-ndk-r15c-linux-x86_64.zip").
   Newer versions are currently not supported. The r15c NDK can be found in the following url:
   https://developer.android.com/ndk/downloads/older_releases.html

   Extract the zip file you downloaded into the "~/Android" folder.
   This should create a "android-ndk-r15c" subfolder.

4) Set the environment variables for Android SDK and NDK tools. 
   For this purpose you can create and use a simple "setenv-android.sh" script.
   In this script define variables for the paths to your SDK tools and NDK. 

   Sample (suggested) script:
          #!/bin/sh

          export ANDROID_HOME=~/Android/android-sdk
          export ANDROID_SDK_ROOT=~/Android/android-sdk
          export ANDROID_NDK_HOME=~/Android/android-ndk-r15c
          export ANDROID_SDK_TOOLS=$ANDROID_HOME/tools
          export ANDROID_SDK_BTOOLS=$ANDROID_HOME/build-tools/26.0.0
          export PATH=$ANDROID_NDK_HOME:$ANDROID_SDK_TOOLS:$ANDROID_SDK_BTOOLS:$PATH

   Save the "setenv-android.sh" script in your "~/Android" folder.
   In order to apply the script run from a shell terminal:
          source ~/Android/setenv-android.sh
   Verify that your environmental variables have been set correctly by running:
          echo $PATH
   You should see your NDK and SDK paths at the start of the $PATH variable.

   WARNING: These environmental variables will be set only for that particular command-line session;
            You will need to re-run this script if you start another shell terminal session.
            You should not re-run this script within the same shell terminal session.

5) Create and put a keystore (you can use the debug version) in "~/.android/debug.keystore".
   To create a debug key store run from the shell terminal:
          keytool -genkey -v -keystore ~/.android/debug.keystore -storepass android -alias androiddebugkey -keypass android -keyalg RSA -keysize 2048 -validity 10000
          keytool -importkeystore -srckeystore ~/.android/debug.keystore -destkeystore ~/.android/debug.keystore -deststoretype pkcs12   
   Enter "android" without the quotes when asked for the keystore password.

6) Clone the ScummVM repository. This guide assumes that you run the clone command from your home directory:
          cd ~
          git clone https://github.com/scummvm/scummvm.git
   The above command will create a "scummvm" folder in your home directory.

7) You can now start building the androidsdl port project by issuing the following commands from the terminal session where you have already set the Android NDK and SDK environmental variables:
          cd ~/scummvm/dists/androidsdl
          ./build.sh

7b) The above build command will create a release build. In order to make a debug build, you will need to add the "debug" argument when running the build command like so:
          ./build.sh debug

8) If the process completes successfully, a "scummvm-debug.apk" file will be stored in that folder (~/scummvm/dists/androidsdl).
    Since this apk is self-signed you will need to enable installation by third-party sources on your Android device in order to install it.


NOTE: You can significantly reduce the build time if you target a specific Android architecture and/or building scummvm for specific game engines only.
      A) In order to target specific architectures edit the following line from the "~/scummvm/dists/androidsdl/scummvm/AndroidAppSettings.cfg" file:
         From:
            MultiABI="armeabi-v7a arm64-v8a x86 x86_64"
         To:
            MultiABI="arm64-v8a"

         The above line is only an example; you might have to specify another architecture for your specific use case.

      B) In order to build the scummvm androidsdl port for specific engines only:
         - Depending on whether you are building a release or a debug build, open one of the "AndroidBuildRelease.sh" or "AndroidBuildDebug.sh" files in the "~/scummvm/dists/androidsdl/scummvm/" folder
         - Find the following line which contains the configure command.
         - Edit the line and after "../configure"  add "--disable-all-engines --enable-engine=YYYY", where in place of "YYYY" you should specify game engine for which you want to build scummvm.
           For example (building only for the bladerunner engine):
           $ANDROIDSDL/project/jni/application/setEnvironment-$1.sh sh -c "cd scummvm/bin-$1 && env LIBS='-lflac -lvorbis -logg -lmad -lz -lgcc -ltheora -lpng -lfreetype -lfaad -lgnustl_static' ../configure --host=androidsdl-$1 --disable-all-engines --enable-engine=bladerunner --enable-zlib --enable-vorbis --enable-mad --enable-flac --enable-png --enable-theoradec --disable-sdlnet --disable-libcurl --disable-cloud --enable-vkeybd --enable-mt32emu --disable-readline --disable-nasm --disable-timidity --disable-fluidsynth --datadir=. "


References:

https://wiki.scummvm.org/index.php/Compiling_ScummVM/Android-SDL
https://forums.scummvm.org/viewtopic.php?t=14811
https://forums.scummvm.org/viewtopic.php?t=14516
http://developer.android.com/tools/publishing/app-signing.html#debugmode