BuildStendhalForAndroid: Difference between revisions

Jump to navigation Jump to search
Content deleted Content added
imported>AntumDeluge
mNo edit summary
imported>AntumDeluge
Building from Command Line: re-organize to make ant preferred build method
 
(25 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{Navigation for Stendhal Top|Building & Hosting}}
{{Navigation for Stendhal Builders and Hosters}}


= WebView Client =
= WebView Client =


== Introduction ==
''<span style="color:red;">'''NOTICE:''' The Android WebView client is not currently implemented in the upstream source code. You can get the experimental source from https://github.com/AntumDeluge/arianne-stendhal/tree/android_webview.</span>''


These instructions are for building the WebView client for the Android platform.
These instructions are for building the [https://developer.android.com/reference/android/webkit/WebView WebView] client for the [https://www.android.com/ 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 [[stendhalgame:client/stendhal.html|https://stendhalgame.org/client/stendhal.html]].


== Android SDK ==
== Android SDK ==
Line 10: Line 16:
The [https://developer.android.com/studio/ Android Software Development Kit (SDK) libraries] are required. You will need to install these on your system. The minimum supported version is currently 21.
The [https://developer.android.com/studio/ Android Software Development Kit (SDK) libraries] are required. You will need to install these on your system. The minimum supported version is currently 21.


== Gradle ==
== Building from IDE ==


=== Android Studio ===
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, & <span style="color:green;">android/gradlew.bat</span> for Windows.


''<span style="color:red;">instructions not yet available</span>''
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 (\\))''.

=== Eclipse ===

''<span style="color:red;">instructions not yet available</span>''

=== Netbeans ===

''<span style="color:red;">instructions not yet available</span>''

== Building from Command Line ==

'''''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 ===

<span style="color:blue;">''Recommended''</span>

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.

'''''See also: [[BuildStendhalForAndroid#Signing_Packages|section on signing packages]]'''''

From the Stendhal source root directory, execute the following.

Unix/Linux example:
<pre>
# 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
</pre>

Windows '''cmd''' example:
<pre>
# 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
</pre>

The resulting .apk packages will be located in the <span style="color:green;"><source root>/build</span> directory.

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>.

<pre>
$ ant android -Dandroid.build=assembleRelease
</pre>

Alternatively, an argument line can be passed to Gradle using the <span style="color:green;">gradle.params</span> property:

<pre>
$ ant android -Dgradle.params="assembleRelease assembleDebug"
</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 Unix/Linux:
Example <span style="color:green;">local.properties</span> for Unix/Linux:
Line 26: Line 93:
</pre>
</pre>


'''NOTE:''' On Windows, if you used Android Studio to download the SDK, it will be located in <span style="color:green;">C:\\Users\\<username>\\AppData\\Local\\Android\\Sdk</span>.
'''''NOTE:''' On Windows, if you used Android Studio to download the SDK, it will be located in <span style="color:green;">C:\\Users\\<username>\\AppData\\Local\\Android\\Sdk</span>.''


From a command line or terminal, move into the <span style="color:green;">android</span> sub-directory & execute the following.
There are two build types available: <span style="color:darkgreen;">assembleRelease</span> and <span style="color:darkgreen;">assembleDebug</span>. From a command line or terminal, move into the <span style="color:green;">app/android</span> sub-directory and execute the following.


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
$ ./gradlew build
$ ./gradlew assembleRelease


# manually setting env variable
# manually setting env variable
$ ANDROID_SDK_ROOT="/path/to/sdk/root" ./gradlew build
$ ANDROID_SDK_ROOT="/path/to/sdk/root" ./gradlew assembleRelease
</pre>
</pre>


Windows '''cmd''' example (note that you do not need to include the ".bat" filename extension):
== Ant ==
<pre>
# with env variable set or sdk.dir set in local.properties
> gradlew assembleRelease


# manually setting env variable (do not use quotes)
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 same rules apply to using the Gradle scripts directly.
> set ANDROID_SDK_ROOT=C:\\path\\to\\sdk\\root
> gradlew assembleRelease
</pre>


If <span style="color:darkgreen;">build</span> is used as the argument (<code>gradlew build</code>), it will execute all build types.
From the Stendhal source root directory, execute the following.


After build completes, the resulting .apk packages will be located in the <span style="color:green;"><source root>/build</span> directory.
Unix/Linux example:
<pre>
# with env variable set or sdk.dir set in local.properties
$ ant dist_client_android


==== Signing Packages ====
# manually setting env variable

$ ANDROID_SDK_ROOT="/path/to/sdk/root" ant dist_client_android
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:

<pre>
storeFile=<path-to-keystore-file>
storePassword=<store-password>
keyPassword=<key-password>
keyAlias=<key-alias>
</pre>
</pre>



The resulting .apk packages will be located in the '''''build''''' directory.
[[Category:Development]]
[[Category:Build]]
[[Category:Web Client]]
[[Category:Android]]