BuildStendhalForAndroid: Difference between revisions
imported>AntumDeluge →Ant: update instructions for recent changes |
imported>AntumDeluge →Building from Command Line: re-organize to make ant preferred build method |
||
| (5 intermediate revisions by the same user not shown) | |||
| Line 34: | Line 34: | ||
'''''IMPORTANT:''' Before you can build from the command line/terminal, you must have a [[VisualGuideToBuildingStendhalStep1|Java compiler]] provided by a [https://www.oracle.com/java/technologies/downloads/ Java Development Kit (JDK)] installed.'' |
'''''IMPORTANT:''' Before you can build from the command line/terminal, you must have a [[VisualGuideToBuildingStendhalStep1|Java compiler]] provided by a [https://www.oracle.com/java/technologies/downloads/ Java Development Kit (JDK)] installed.'' |
||
=== |
=== Ant === |
||
| ⚫ | |||
| ⚫ | The [https://gradle.org/ Gradle Build Tool] is used for building. The necessary tools are already included with the source code. Two scripts are provided for executing the build: <span style="color:green;">android/gradlew</span> for Unix/Linux systems |
||
| ⚫ | As with other instructions on building from the command line, the Android client can also be built with an [https://ant.apache.org/ Apache Ant target]. The Ant target is a wrapper that calls the [[BuildStendhalForAndroid#Gradle|Gradle]] script and passes parameters to it. The same conditions related to invoking the Gradle scripts directly apply to using ant. |
||
| ⚫ | In order for the build to complete, the scripts must know where the SDK libraries are located. The script will check the '''<span style="color:green;">ANDROID_SDK_ROOT</span>''' environment variable, or it will parse the value of '''<span style="color:green;">sdk.dir</span>''' in the <span style="color:green;">android/local.properties</span> file ''('''NOTE:''' Windows users must use double backslashes for directories (\\))''. |
||
'''''See also: [[BuildStendhalForAndroid#Signing_Packages|section on signing packages]]''''' |
|||
| ⚫ | |||
| ⚫ | |||
| ⚫ | |||
| ⚫ | |||
| ⚫ | |||
| ⚫ | |||
| ⚫ | |||
| ⚫ | |||
| ⚫ | |||
| ⚫ | |||
| ⚫ | There are |
||
Unix/Linux example: |
Unix/Linux example: |
||
<pre> |
<pre> |
||
# with env variable set or sdk.dir set in local.properties |
# with env variable set or sdk.dir set in local.properties |
||
| ⚫ | |||
| ⚫ | |||
# manually setting env variable |
# manually setting env variable |
||
$ ANDROID_SDK_ROOT="/path/to/sdk/root" |
$ ANDROID_SDK_ROOT="/path/to/sdk/root" ant android |
||
</pre> |
</pre> |
||
Windows '''cmd''' example |
Windows '''cmd''' example: |
||
<pre> |
<pre> |
||
# with env variable set or sdk.dir set in local.properties |
# with env variable set or sdk.dir set in local.properties |
||
| ⚫ | |||
| ⚫ | |||
# manually setting env variable (do not use quotes) |
# manually setting env variable (do not use quotes) |
||
> set ANDROID_SDK_ROOT=C:\\path\\to\\sdk\\root |
> set ANDROID_SDK_ROOT=C:\\path\\to\\sdk\\root |
||
| ⚫ | |||
| ⚫ | |||
</pre> |
</pre> |
||
| ⚫ | |||
| ⚫ | |||
The build type can be set manually using the <span style="color:green;">android.build</span> property. Value can be one of <span style="color:green;">assembleRelease</span> or <span style="color:green;">assembleDebug</span>. The default is <span style="color:green;">assembleDebug</span>. |
|||
After build completes, the resulting .apk packages will be located in <span style="color:green;"><source root>/build/build_android_client/outputs/apk</span>. |
|||
| ⚫ | |||
| ⚫ | |||
| ⚫ | |||
| ⚫ | |||
Alternatively, an argument line can be passed to Gradle using the <span style="color:green;">gradle.params</span> property: |
|||
| ⚫ | On most Android systems packages will [https://developer.android.com/studio/publish/app-signing need to be signed] in order to work. By default Gradle will sign packages using a debugging keystore which must |
||
<pre> |
<pre> |
||
$ ant android -Dgradle.params="assembleRelease assembleDebug" |
|||
| ⚫ | |||
| ⚫ | |||
| ⚫ | |||
| ⚫ | |||
</pre> |
</pre> |
||
=== |
=== Gradle === |
||
| ⚫ | The [https://gradle.org/ Gradle Build Tool] is used for building. The necessary tools are already included with the source code. Two scripts are provided for executing the build: <span style="color:green;">app/android/gradlew</span> for Unix/Linux systems and <span style="color:green;">app/android/gradlew.bat</span> for Windows. |
||
| ⚫ | |||
| ⚫ | In order for the build to complete, the scripts must know where the SDK libraries are located. The script will check the '''<span style="color:green;">ANDROID_SDK_ROOT</span>''' environment variable, or it will parse the value of '''<span style="color:green;">sdk.dir</span>''' in the <span style="color:green;">app/android/local.properties</span> file ''('''NOTE:''' Windows users must use double backslashes for directories (\\))''. |
||
| ⚫ | |||
| ⚫ | |||
| ⚫ | |||
| ⚫ | |||
| ⚫ | |||
Example <span style="color:green;">local.properties</span> for Windows: |
|||
| ⚫ | |||
| ⚫ | |||
| ⚫ | |||
| ⚫ | |||
| ⚫ | |||
Unix/Linux example: |
Unix/Linux example: |
||
<pre> |
<pre> |
||
# with env variable set or sdk.dir set in local.properties |
# with env variable set or sdk.dir set in local.properties |
||
| ⚫ | |||
| ⚫ | |||
# manually setting env variable |
# manually setting env variable |
||
$ ANDROID_SDK_ROOT="/path/to/sdk/root" |
$ ANDROID_SDK_ROOT="/path/to/sdk/root" ./gradlew assembleRelease |
||
</pre> |
</pre> |
||
Windows '''cmd''' example: |
Windows '''cmd''' example (note that you do not need to include the ".bat" filename extension): |
||
<pre> |
<pre> |
||
# with env variable set or sdk.dir set in local.properties |
# with env variable set or sdk.dir set in local.properties |
||
| ⚫ | |||
| ⚫ | |||
# manually setting env variable (do not use quotes) |
# manually setting env variable (do not use quotes) |
||
> set ANDROID_SDK_ROOT=C:\\path\\to\\sdk\\root |
> set ANDROID_SDK_ROOT=C:\\path\\to\\sdk\\root |
||
| ⚫ | |||
| ⚫ | |||
</pre> |
</pre> |
||
| ⚫ | |||
| ⚫ | |||
After build completes, the resulting .apk packages will be located in the <span style="color:green;"><source root>/build</span> directory. |
|||
| ⚫ | |||
| ⚫ | |||
| ⚫ | |||
| ⚫ | |||
| ⚫ | On most Android systems packages will [https://developer.android.com/studio/publish/app-signing need to be signed] in order to work. By default Gradle will sign packages using a debugging keystore which must be installed in your home directory. You can specify a different keystore by creating a file <span style="color:darkblue;">app/android/keystore.properties</span> with contents as follows: |
||
=== Setting Revision Suffix === |
|||
The compiled .apk packages will be versioned with the date of build. A custom revision suffix can be added by setting the <span style="color:darkgreen;">android.rev</span> property. If invoking gradle script directly, use the '''''-P''''' switch. If calling ant, use the '''''-D''''' switch. |
|||
Example usage: |
|||
<pre> |
<pre> |
||
| ⚫ | |||
# calling gradle script directly |
|||
| ⚫ | |||
$ ./gradlew assembleDebug -Pandroid.rev=1 |
|||
| ⚫ | |||
| ⚫ | |||
# calling ant target |
|||
$ ant dist_client_android -Dandroid.rev=1 |
|||
</pre> |
</pre> |
||
Example output: ''stendhal-webview-{{#time:Ymd}}-1-debug.apk'' |
|||
Latest revision as of 00:58, 31 December 2025
WebView Client
Introduction
These instructions are for building the WebView client for the Android platform.
What is a WebView Client?
WebView is an application that allows embedding or linking to websites or HTML code inside Android apps. The Stendhal WebView client is an app that simply uses this technology to link to the Stendhal web client which is accessed at https://stendhalgame.org/client/stendhal.html.
Android SDK
The Android Software Development Kit (SDK) libraries are required. You will need to install these on your system. The minimum supported version is currently 21.
Building from IDE
Android Studio
instructions not yet available
Eclipse
instructions not yet available
Netbeans
instructions not yet available
Building from Command Line
IMPORTANT: Before you can build from the command line/terminal, you must have a Java compiler provided by a Java Development Kit (JDK) installed.
Ant
Recommended
As with other instructions on building from the command line, the Android client can also be built with an Apache Ant target. The Ant target is a wrapper that calls the Gradle script and passes parameters to it. The same conditions related to invoking the Gradle scripts directly apply to using ant.
See also: section on signing packages
From the Stendhal source root directory, execute the following.
Unix/Linux example:
# with env variable set or sdk.dir set in local.properties $ ant android # manually setting env variable $ ANDROID_SDK_ROOT="/path/to/sdk/root" ant android
Windows cmd example:
# with env variable set or sdk.dir set in local.properties > ant android # manually setting env variable (do not use quotes) > set ANDROID_SDK_ROOT=C:\\path\\to\\sdk\\root > ant android
The resulting .apk packages will be located in the <source root>/build directory.
The build type can be set manually using the android.build property. Value can be one of assembleRelease or assembleDebug. The default is assembleDebug.
$ ant android -Dandroid.build=assembleRelease
Alternatively, an argument line can be passed to Gradle using the gradle.params property:
$ ant android -Dgradle.params="assembleRelease assembleDebug"
Gradle
The Gradle Build Tool is used for building. The necessary tools are already included with the source code. Two scripts are provided for executing the build: app/android/gradlew for Unix/Linux systems and app/android/gradlew.bat for Windows.
In order for the build to complete, the scripts must know where the SDK libraries are located. The script will check the ANDROID_SDK_ROOT environment variable, or it will parse the value of sdk.dir in the app/android/local.properties file (NOTE: Windows users must use double backslashes for directories (\\)).
Example local.properties for Unix/Linux:
sdk.dir=/path/to/sdk/root
Example local.properties for Windows:
sdk.dir=C:\\path\\to\\sdk\\root
NOTE: On Windows, if you used Android Studio to download the SDK, it will be located in C:\\Users\\<username>\\AppData\\Local\\Android\\Sdk.
There are two build types available: assembleRelease and assembleDebug. From a command line or terminal, move into the app/android sub-directory and execute the following.
Unix/Linux example:
# with env variable set or sdk.dir set in local.properties $ ./gradlew assembleRelease # manually setting env variable $ ANDROID_SDK_ROOT="/path/to/sdk/root" ./gradlew assembleRelease
Windows cmd example (note that you do not need to include the ".bat" filename extension):
# with env variable set or sdk.dir set in local.properties > gradlew assembleRelease # manually setting env variable (do not use quotes) > set ANDROID_SDK_ROOT=C:\\path\\to\\sdk\\root > gradlew assembleRelease
If build is used as the argument (gradlew build), it will execute all build types.
After build completes, the resulting .apk packages will be located in the <source root>/build directory.
Signing Packages
On most Android systems packages will need to be signed in order to work. By default Gradle will sign packages using a debugging keystore which must be installed in your home directory. You can specify a different keystore by creating a file app/android/keystore.properties with contents as follows:
storeFile=<path-to-keystore-file> storePassword=<store-password> keyPassword=<key-password> keyAlias=<key-alias>