Difference between revisions of "Android"

From Minetest Developer Wiki
Jump to navigation Jump to search
m
 
(65 intermediate revisions by 9 users not shown)
Line 1: Line 1:
= Minetest on Android =
+
= Building Android =
== Building ==
 
What you need:
 
* Linux
 
* Android NDK '''Crystax version'''
 
* An Android device, preferably rooted
 
* Subversion, Git, CMake
 
* 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 ===
 
Clone <code>svn://svn.code.sf.net/p/irrlicht/code/branches/ogl-es</code>.
 
  
Replace <code>source/Irrlicht/Makefile</code> with https://ghostbin.com/paste/2rfyo.
+
See https://github.com/minetest/minetest/blob/master/doc/README.android
 
 
Replace <code>include/irrCompileConfig.h</code> with https://ghostbin.com/paste/dwn5a.
 
 
 
Make sure you have arm-linux-androideabi-gcc and arm-linux-androideabi-g++ usable and run <code>make</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.git</code> and switch to the <code>android</code> branch.
 
Configure it using CMake like this:
 
<pre>
 
$ 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>
 
</pre>
 
Now just enter ''make package'' and it will create <code>src/libminetest.so</code> and a package with all resources.
 
== Running ==
 
For this step you need minetest-x.x.x.tar.gz and libminetest.so from the previous step.
 
 
 
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>.
 
 
 
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>).
 
If it does not start you can use ADB's LogCat to see messages for <code>com.sfan5.irrlichtexample01</code>.
 

Latest revision as of 19:42, 18 June 2022