02-08-2016, 05:44 AM
This is introduction. You can skip it if you like.
It seems that there is no official build of Cuberite available for Android devices yet. And I can't figure out how to build it. I never liked cmake and git, especially it's "module" feature. I already forgot how to deal with complex projects in Android NDK (And I hate that too). So I've chosen simple way: run already existing binaries. "But there isn't any binaries available for Android, didn't you mention that?" - can you ask. Yes, there isn't. But there is a everyday binary build for Raspberry Pi available. It's not Android? Who cares? This is powered by Linux kernel, and that is powered by Linux kernel. Both are ARM (ARMv7 with hard-float support, to be precise). And that's all that matters.
So, that do you need to run Cuberite natively on Android device?
So, that's all you need to run Cuberite natively on Android device. So many words but it's really very simple =)
P.S.: I though that it will be boring to go through this WALL of text just to figure out that you don't want to try this, so there is some screenshots for fun!
P.P.S: It seems that I can't upload files larger than 1024k to forum, so I put archive here. It's only slightly larger than 1Mb, maybe 1.5Mb or so.
Quote:Some time ago I was having a thought about running Minecraft server on Android devices. Why? Because it's seems to be simple and available for anyone who has Android device. Not to mention that nowadays Android can be found on big range of devices, from small phones to powerful 8-core devices. You don't need to find and by it somethere, it's already in your pocket.
But there was a obvious problem: no official build for Android. There is a official PE edition and that's all. With help of MCP I've tried to rebuild official server for Android, but encountered some problems (I can't exactly say that it was, I forgot already. Maybe something related to restriction on number of methods in one DEX file, or something similar). Besides that, what about mods? It will not be trivial to install them. So I searched for alternative servers, but most of them had their source code closed or were abandoned long time ago. One of the promising was MCServer (and I even managed to compile it), but there was another problems. Maybe with stability, maybe this something else - can't remember, it was several years ago, two or free, maybe. At that time I dropped this idea. But several days ago, while cleaning my HDD from old files, I found folder "MCServer" and decided to try it again.
It seems that there is no official build of Cuberite available for Android devices yet. And I can't figure out how to build it. I never liked cmake and git, especially it's "module" feature. I already forgot how to deal with complex projects in Android NDK (And I hate that too). So I've chosen simple way: run already existing binaries. "But there isn't any binaries available for Android, didn't you mention that?" - can you ask. Yes, there isn't. But there is a everyday binary build for Raspberry Pi available. It's not Android? Who cares? This is powered by Linux kernel, and that is powered by Linux kernel. Both are ARM (ARMv7 with hard-float support, to be precise). And that's all that matters.
So, that do you need to run Cuberite natively on Android device?
- Of course, you will need Cuberite. You can get most recent build from buildbot here: Cuberite for Raspberry Pi
- Cuberite is compiled against some system libraries, and of course, you will need them too. You can get list of libraries by examining executable with ldd Unix tool. To put it simply, you will need libgcc, libc6 and libstdc++ packages from Raspbian repository. Be aware that library names in executable refers to symlinks; real names of .so files differs. Be sure to rename them correspondingly.
- I would like to say "that's all you need", but it's not that simple. To be precise, you need to somehow provide this libraries to executable. Now you have two choices: 4) modify your Android system or 5) modify executable
- If you decided to modify system, it's not that hard, and should be done only once. Later you will only need to download recent build of Cuberite and run it. Cuberite, as a normal Linux dynamic executable, expects to find libraries in /lib or /usr/lib directory of file system. (To be precise, it's not Cuberite but dynamic linker that will search for libraries. You can specify library location with LD_LIBRARY_PATH environment variable, but path to dynamic linker is hardcoded into executable, so it must reside at /lib.) Unfortunately, there is no such directories in Android, and even worse: using root access you can create /lib directory, but it will disappear after reboot, because all changes to / only affects it's temporary memory copy. At this point you again have two ways: modify your boot.img firmware image to create /lib directory there or use already modified boot.img with init.d support and write a script that will at every boot create /lib directory and put neccessary files there. I leave this up to you, it's not very hard, but can be somethat dangerous if you have no experience in Android modding.
- If you decided to modify Cuberite executable, you should be aware that you will need to do this every time you download new build. But it's not very complicated; in reality, it is only one shell command. The tool that you will need for that task is a Patchelf. If you using any modern Linux distro, it should be already in its repo. Unfortunately, official builds of Patchelf fails to work with ARM bianries, and I'm not sure is Debian/Ubuntu version fixed or not (at least Gentoo version isn't). You can download source for patched version from this Github repo and compile it by yourself. After you got it, just say patchelf --set-interpreter /path/to/where/you/placed/dynamic/linker to specify where linker that should be used to load executable is located. In my case, it will be /sdcard/Cuberite/Libraries/ld-linux-armhf.so.3, but yours may differ. And again, you have two options: hardcode path to other libraries to executable (see --set-rpath option of Patchelf) or specify it on a runtime with LD_LIBRARY_PATH. It's up to you.
So, that's all you need to run Cuberite natively on Android device. So many words but it's really very simple =)
P.S.: I though that it will be boring to go through this WALL of text just to figure out that you don't want to try this, so there is some screenshots for fun!
P.P.S: It seems that I can't upload files larger than 1024k to forum, so I put archive here. It's only slightly larger than 1Mb, maybe 1.5Mb or so.