Difference between revisions of "Android"

From Minetest Developer Wiki
Jump to navigation Jump to search
m
(Update for new (and improved) build system)
Line 4: Line 4:
 
* Linux
 
* Linux
 
* Android NDK '''Crystax version'''
 
* Android NDK '''Crystax version'''
 +
* Android SDK
 
* An Android device, preferably rooted
 
* An Android device, preferably rooted
 
* Subversion, Git, CMake
 
* Subversion, Git, CMake
 +
* Ant
 
* ADB (optional but very useful)
 
* ADB (optional but very useful)
=== Setting up the toolchain ===
 
Copy <code><ndk root>/sources/android/native_app_glue/android_native_app_glue.h</code> into <code><toolchain root>/sysroot/usr/include</code>.
 
 
=== Irrlicht ===
 
=== Irrlicht ===
 
Clone <code>svn://svn.code.sf.net/p/irrlicht/code/branches/ogl-es</code>.
 
Clone <code>svn://svn.code.sf.net/p/irrlicht/code/branches/ogl-es</code>.
Line 20: Line 20:
 
This will build Irrlicht as static and shared library and place it in <code>lib/Linux</code>
 
This will build Irrlicht as static and shared library and place it in <code>lib/Linux</code>
 
=== Minetest ===
 
=== Minetest ===
Clone <code>https://github.com/sfan5/minetest.git</code> and switch to the <code>android</code> branch.
+
Clone <code>https://github.com/sfan5/minetest.git</code> and switch to the <code>android_new</code> branch.
 
Configure it using CMake like this:
 
Configure it using CMake like this:
 
<pre>
 
<pre>
Line 32: Line 32:
 
     -DCMAKE_SYSTEM_NAME=Linux \
 
     -DCMAKE_SYSTEM_NAME=Linux \
 
     -DIRRLICHT_LIBRARY=<path to libIrrlicht.a> \
 
     -DIRRLICHT_LIBRARY=<path to libIrrlicht.a> \
     -DIRRLICHT_INCLUDE_DIR=<patch to include/ of Irrlicht>
+
     -DIRRLICHT_INCLUDE_DIR=<patch to include/ of Irrlicht> \
 +
    -DANDROID=1
 
</pre>
 
</pre>
Now just enter <code>make package</code> and it will create <code>src/libminetest.so</code> and a package with all resources.
+
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 ==
 
== Running ==
For this step you need minetest-x.x.x.tar.gz and libminetest.so from the previous step.
+
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.
 
Put all resource files & folders (builtin, client, ...) into <code>/sdcard/minetest</code> on your Android device.
Download <code>http://sfan5.duckdns.org/upload/userdata/1/MinetestLoader.apk</code>.
+
Install <code>Minetest-debug.apk</code>.
 
 
If you don't have a rooted device you need to use an hex editor to edit the shared library and change the path of minetest.so to <code>/data/local/tmp/minetest.so</code> and put libminetest.so at <code>/data/local/tmp/minetest.so</code> on your Android device.
 
 
 
If you do have a rooted device just put libminetest.so at <code>/sdcard/minetest/minetest.so</code> and run <code>mount - /sdcard -o remount,exec</code> to allow the Loader app to load shared libraries from the external storage.
 
  
After you've done that just launch the Load application (currently called <code>IrrlichtExample01</code>).
+
Now touch the Minetest icon and the lovely main menu should appear. ;-)
If it does not start you can use ADB's LogCat to see messages for <code>com.sfan5.irrlichtexample01</code>.
 

Revision as of 16:16, 15 January 2014

Minetest on Android

Building

What you need:

  • Linux
  • Android NDK Crystax version
  • Android SDK
  • An Android device, preferably rooted
  • Subversion, Git, CMake
  • Ant
  • ADB (optional but very useful)

Irrlicht

Clone svn://svn.code.sf.net/p/irrlicht/code/branches/ogl-es.

Replace source/Irrlicht/Makefile with https://ghostbin.com/paste/2rfyo.

Replace include/irrCompileConfig.h with https://ghostbin.com/paste/dwn5a.

Make sure you have arm-linux-androideabi-gcc and arm-linux-androideabi-g++ usable and run make.

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

Minetest

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

$ cmake . \
    -DCMAKE_C_COMPILER=`which arm-linux-androideabi-gcc` \
    -DCMAKE_CXX_COMPILER=`which arm-linux-androideabi-g++` \
    -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=<patch to include/ of Irrlicht> \
    -DANDROID=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. ;-)