Difference between revisions of "Android"

From Minetest Developer Wiki
Jump to navigation Jump to search
(Replaced vague descriptions about how to build with concrete set of steps executable in a terminal)
 
(20 intermediate revisions by 4 users not shown)
Line 1: Line 1:
= Building Android from master branch =
+
= Building Android =
  
This is a simple guide on how to build Minetest for Android on Ubuntu <b>on a 64 bit system</b>. Building on 32 bit systems should work too when the URLs and paths are replaced accordingly. This guide covers all preparation needed. Once everything is set up, Minetest only needs <code>cd build/android && make</code> to compile.
+
See https://github.com/minetest/minetest/blob/master/doc/README.android
 
 
=== Required packages ===
 
Git, Make, and Gradle are neccessary: <br\><br/>
 
<code>
 
sudo add-apt-repository ppa:cwchien/gradle<br/>
 
sudo apt-get update<br/>
 
sudo apt-get install make m4 subversion git-core build-essential gradle-2.13 realpath openjdk-7-jdk
 
</code><br/><br/>
 
As your architecture is 64 bit, you need additional packages:<br/><br/>
 
<code>
 
sudo apt-get install --force-yes libgd2-xpm ia32-libs ia32-libs-multiarch
 
</code>
 
 
 
=== Getting the SDK and NDK ===
 
 
 
<code>
 
wget https://dl.google.com/android/android-sdk_r24.4.1-linux.tgz
 
wget https://dl.google.com/android/repository/android-ndk-r11c-linux-x86_64.zip
 
 
 
tar xf android-sdk_r24.4.1-linux.tgz
 
unzip android-ndk-r11c-linux-x86_64.zip
 
 
 
android-sdk-linux/tools/android update sdk --no-ui -a --filter platform-tool,android-23,build-tools-23.0.3
 
</code>
 
 
 
The last line will ask for your confirmation multiple times.
 
 
 
=== Obtaining and building Minetest ===
 
Clone Minetest, and build it:<br/><br/>
 
<code>
 
git clone --depth 1 https://github.com/minetest/minetest.git <br\>
 
cd minetest/build/android <br\>
 
make <br\>
 
</code>
 
 
 
The make file will ask you for the paths to your SDK and NDK.  It will then download and build all required libraries.  Finally it will build Minetest and the Java sources and pack everything into a debug-signed APK.
 
 
 
= [[User:Sfan5|sfan5]]'s Android port =
 
== Building and Running ==
 
=== Building ===
 
What you need:
 
* GNU/Linux
 
* Android NDK
 
* Standalone toolchain made with Android NDK (with <code>android_native_app_glue.h</code> copied into <code><TOOLCHAIN_ROOT>/sysroot/usr/include</code>)
 
:* '''You need to use Clang''' as GCC produces broken code
 
* Android SDK
 
* Android device
 
* Git
 
* CMake
 
* Ant
 
* ''ADB (optional but very useful)''
 
 
 
==== Irrlicht ====
 
 
 
Clone <code>https://github.com/sfan5/irrlicht-android</code>.
 
 
 
Make sure you have arm-linux-androideabi-gcc ''(It's ok to use gcc for Irrlicht)'' and arm-linux-androideabi-g++ usable and run <code>make</code> in <code>source/Irrlicht</code>.
 
 
 
This will build Irrlicht as static and shared library and place it in <code>lib/Linux</code>
 
 
 
==== Minetest ====
 
 
 
Clone <code>https://github.com/sfan5/minetest</code> and switch to the <code>android_new</code> branch.
 
Configure it using CMake like this:
 
<pre>
 
$ cmake . \
 
    -DCMAKE_C_COMPILER=`which arm-linux-androideabi-clang` \
 
    -DCMAKE_CXX_COMPILER=`which arm-linux-androideabi-clang++` \
 
    -DCMAKE_FIND_ROOT_PATH=<sysroot of your android toolchain> \
 
    -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY \
 
    -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY \
 
    -DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=BOTH \
 
    -DCMAKE_SYSTEM_NAME=Linux \
 
    -DIRRLICHT_LIBRARY=<path to libIrrlicht.a> \
 
    -DIRRLICHT_INCLUDE_DIR=<path to include/ of Irrlicht> \
 
    -DANDROID=1 \
 
    -DANDROID_SUPPORT_LIBRARY=<path to libandroid_support.a> \
 
    -DANDROID_SUPPORT_INCLUDE_DIR=<patch to <NDK_DIR>/source/android/support/include> \
 
    -DRUN_IN_PLACE=1
 
</pre>
 
Now just enter <code>make package</code>.
 
After make is done go into the <code>Android</code> directory and run <code><SDK_DIR>/tools/android update project --path .</code>.
 
 
 
Then copy the .so using <code><NDK_DIR>/ndk-build</code> and build the apk using <code>ant debug</code>.
 
 
 
You will then have the resources in minetest-''x.x.x''.tar.gz and the apk at <code>Android/bin/Minetest-debug.apk</code>.
 
You will only need to do the “Android update project” step once.
 
 
 
=== Running ===
 
 
 
For this step you need '''minetest-''x.x.x''.tar.gz''' and '''Minetest-debug.apk''' from the previous step.
 
 
 
Put all resource files & folders (builtin, client, ...) into <code>/sdcard/minetest</code> on your Android device.
 
Install <code>Minetest-debug.apk</code>.
 
 
 
Now touch the Minetest icon and the lovely main menu should appear.
 
 
 
== Development notes ==
 
 
 
=== General notes ===
 
 
 
* cURL does not work
 
:* TLS support is needed too
 
::* Idea: Use GnuTLS or LibreSSL, because OpenSSL is a nightmare to cross-compile
 
* Add Bluetooth support for local multiplayer (maybe)
 
:* see (http://people.csail.mit.edu/albert/bluez-intro/x559.html or http://people.csail.mit.edu/albert/bluez-intro/x502.html) and https://github.com/sfan5/minetest/tree/bluetooth
 
* OpenAL with Android support: https://github.com/AerialX/openal-soft-android
 
 
 
=== Getting stuff to work without libCrystax ===
 
 
 
* Frequently crashes after going through <code>std::ios_base::~ios_base()</code>
 
:* Probably related to removal of libCrystax
 
* Pressing a button now roughly equals taking away a wood piece of a unstable Jenga tower
 
* Options:
 
:* Use libc++
 
::* Currently a problem with includes
 
:* avoid destructing any streams
 
::* This is not a good idea
 
:* Go back to Crystax toolchain
 
::* Uhh… no!
 
 
 
 
 
=== References ===
 
 
 
<references/>
 
[[Category:Compiling Minetest]]
 

Latest revision as of 19:42, 18 June 2022