Difference between revisions of "Android"

From Minetest Developer Wiki
Jump to navigation Jump to search
m (→‎Getting the SDK and NDK: Update sdk update command)
m (→‎Getting the SDK and NDK: Update needed NDK version and build-tools)
Line 32: Line 32:
 
<code>
 
<code>
 
wget https://dl.google.com/android/android-sdk_r24.4.1-linux.tgz <br\>
 
wget https://dl.google.com/android/android-sdk_r24.4.1-linux.tgz <br\>
wget https://dl.google.com/android/repository/android-ndk-r11c-linux-x86_64.zip <br\>
+
wget https://dl.google.com/android/repository/android-ndk-r16b-linux-x86_64.zip <br\>
 
<br\>
 
<br\>
 
tar xf android-sdk_r24.4.1-linux.tgz <br\>
 
tar xf android-sdk_r24.4.1-linux.tgz <br\>
unzip android-ndk-r11c-linux-x86_64.zip <br\>
+
unzip android-ndk-r16b-linux-x86_64.zip <br\>
 
<br\>
 
<br\>
android-sdk-linux/tools/android update sdk --no-ui -a --filter platform-tool,android-25,build-tools-25.0.1 <br\>
+
android-sdk-linux/tools/android update sdk --no-ui -a --filter platform-tool,android-25,build-tools-25.0.3 <br\>
 
</code>
 
</code>
  

Revision as of 19:00, 11 March 2018

Building Android from master branch

This is a simple guide on how to build Minetest for Android on Ubuntu on a 64 bit system. 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 cd build/android && make to compile.

Required packages

Git, Make, and other basic tools are neccessary: <br\>
sudo apt-get update
sudo apt-get install make m4 subversion git-core build-essential realpath openjdk-8-jdk


Gradle is required as well. If your distribution gives you gradle 2.10 or later (like Ubuntu 16.04 does), you may simply do:

sudo apt-get install gradle

If your distribution ships with an older version of gradle, you may grab a recent version of gradle via a PPA:

sudo add-apt-repository ppa:cwchien/gradle
sudo apt-get install gradle-2.13


As your architecture is 64 bit, you need additional packages.

On newer systems do: (Ubuntu 16.04-ish):

sudo apt-get install lib32z1

On older systems do:

sudo apt-get install --force-yes libgd2-xpm ia32-libs ia32-libs-multiarch

Getting the SDK and NDK

Both SDK and NDK are needed:

wget https://dl.google.com/android/android-sdk_r24.4.1-linux.tgz <br\> wget https://dl.google.com/android/repository/android-ndk-r16b-linux-x86_64.zip <br\> <br\> tar xf android-sdk_r24.4.1-linux.tgz <br\> unzip android-ndk-r16b-linux-x86_64.zip <br\> <br\> android-sdk-linux/tools/android update sdk --no-ui -a --filter platform-tool,android-25,build-tools-25.0.3 <br\>

The last line will ask for your confirmation multiple times.

Obtaining and building Minetest

Clone Minetest, and build it:

git clone --depth 1 https://github.com/minetest/minetest.git <br\> cd minetest/build/android <br\> make <br\>

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.

sfan5's Android port

Building and Running

Building

What you need:

  • GNU/Linux
  • Android NDK
  • Standalone toolchain made with Android NDK (with android_native_app_glue.h copied into <TOOLCHAIN_ROOT>/sysroot/usr/include)
  • You need to use Clang as GCC produces broken code
  • Android SDK
  • Android device
  • Git
  • CMake
  • Ant
  • ADB (optional but very useful)

Irrlicht

Clone https://github.com/sfan5/irrlicht-android.

Make sure you have arm-linux-androideabi-gcc (It's ok to use gcc for Irrlicht) and arm-linux-androideabi-g++ usable and run make in source/Irrlicht.

This will build Irrlicht as static and shared library and place it in lib/Linux

Minetest

Clone https://github.com/sfan5/minetest and switch to the android_new branch. Configure it using CMake like this:

$ 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

Now just enter make package. After make is done go into the Android directory and run <SDK_DIR>/tools/android update project --path ..

Then copy the .so using <NDK_DIR>/ndk-build and build the apk using ant debug.

You will then have the resources in minetest-x.x.x.tar.gz and the apk at Android/bin/Minetest-debug.apk. 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 /sdcard/minetest on your Android device. Install Minetest-debug.apk.

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)

Getting stuff to work without libCrystax

  • Frequently crashes after going through std::ios_base::~ios_base()
  • 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