Difference between revisions of "Android"

From Minetest Developer Wiki
Jump to navigation Jump to search
m
m
Line 4: Line 4:
 
== Building ==
 
== Building ==
 
What you need:
 
What you need:
* Linux
+
* GNU/Linux
 
* Android NDK
 
* 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>)
+
* 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
+
:* '''You need to use Clang''' as GCC produces broken code
 
* Android SDK
 
* Android SDK
 
* Android device
 
* Android device
Line 13: Line 13:
 
* CMake
 
* CMake
 
* Ant
 
* Ant
* ADB (optional but very useful)
+
* ''ADB (optional but very useful)''
 +
 
 
=== Irrlicht ===
 
=== Irrlicht ===
 +
 
Clone <code>https://github.com/sfan5/irrlicht-android</code>.
 
Clone <code>https://github.com/sfan5/irrlicht-android</code>.
  
Line 22: Line 24:
  
 
=== Minetest ===
 
=== Minetest ===
 +
 
Clone <code>https://github.com/sfan5/minetest</code> and switch to the <code>android_new</code> branch.
 
Clone <code>https://github.com/sfan5/minetest</code> and switch to the <code>android_new</code> branch.
 
Configure it using CMake like this:
 
Configure it using CMake like this:
Line 47: Line 50:
 
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 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.
 
You will only need to do the "android update project" step once.
 +
 
== Running ==
 
== Running ==
 +
 
For this step you need minetest-''x.x.x''.tar.gz and Minetest-debug.apk from the previous step.
 
For this step you need minetest-''x.x.x''.tar.gz and Minetest-debug.apk from the previous step.
  
Line 55: Line 60:
 
Now touch the Minetest icon and the lovely main menu should appear. ;-)
 
Now touch the Minetest icon and the lovely main menu should appear. ;-)
  
= Dev Notes =
+
= Development notes =
 +
 
 
== General notes ==
 
== General notes ==
 +
 
* cURL does not work
 
* cURL does not work
 
:* TLS support is needed too
 
:* TLS support is needed too
Line 63: Line 70:
 
:* 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
 
:* 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
 
* OpenAL with Android support: https://github.com/AerialX/openal-soft-android
 +
 
== Getting stuff to work without libCrystax ==
 
== Getting stuff to work without libCrystax ==
 +
 
* Frequently crashes after going through <code>std::ios_base::~ios_base()</code>
 
* Frequently crashes after going through <code>std::ios_base::~ios_base()</code>
 
:* Probably related to removal of libCrystax
 
:* Probably related to removal of libCrystax
 
* Pressing a button now roughly equals taking away a wood piece of a unstable Jenga tower
 
* Pressing a button now roughly equals taking away a wood piece of a unstable Jenga tower
 
* Options:
 
* Options:
:* use libc++  
+
:* Use libc++  
::* currently a problem with includes
+
::* Currently a problem with includes
 
:* avoid destructing any streams
 
:* avoid destructing any streams
 
::* This is not a good idea
 
::* This is not a good idea
 
:* Go back to Crystax toolchain
 
:* Go back to Crystax toolchain
::* uhh... no!
+
::* Uhh… no!
 +
 
  
 +
== References ==
  
References:
 
 
<references/>
 
<references/>

Revision as of 10:14, 7 December 2014

This page is about the WIP Android port by sfan5, not about the official 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 and its code is shit[1]
  • 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