Author Topic: Android - new try  (Read 3868 times)

0 Members and 1 Guest are viewing this topic.

Hi everyone,

tl;dr:
- I successfully compiled fs2open on android with Antipodes, since this branch uses SDL2.
- However it crashes.
- you can grab the android project here: http://tinyurl.com/hjx2heo

details:
I'm new here.
I own a Nvidia Shield TV, and I thought it would be cool if FSO could run on it.
I did not find much information on FSO and Android, so I assumed that it did not work as of yet.

I successfully made it compile with Antipodes, since this branch uses SDL2. However it crashes.
I am not able to continue right now, but I give the instructions here in the case someone wants to pursue this work (and this someone may be me in the future).

I first followed the steps here: https://wiki.libsdl.org/Android to install SDL in a GCC toolchain (4.2).
Make sure to update the PATH so the compiler/linker binaries are found.

Then I did the very first step of 4.4: "Copy and adapt the /usr/src/SDL2/android-project skeleton as explained in README-android.md. You can leave it as-is in a first step."
I renamed the project (or dir name) to fs2open-android.

I got the git repo of regal (GL on top of GLES) and openal-soft, and the tar balls of ogg, vorbis, theora.
I put regal and openal-soft in fs2open-android and ogg, vorbis and theora in fs2open-android/jni/src. The reason is that regal and openal-soft have a build procedure for Android, while I just compile the c files of ogg, vorbis and theora (I do not bother making a lib, all .o are linked against the final binary)
for regal and openal-soft I had to make a few adjustments.
I provide a tarball with everything included here: http://tinyurl.com/hjx2heo

go into regal/build/android/Regal/ and do a nkd-build (it takes a while)
then copy  regal/build/android/Regal/obj/local/armeabi-v7a/lib* in ($NDK_ROOT)/sysroot/usr/lib
 
go into openal-soft/build and do what's explained in ../XCompile-Android.txt:
edit /XCompile-Android.txt to set the NDK_ROOT path: $(NDK_ROOT)/sysroot/usr
$ cmake .. -DCMAKE_TOOLCHAIN_FILE=../XCompile-Android.txt -DHOST=arm-linux-androideabi
make sure OpenSLES backend is selected: edit CMakeLists.txt. (I also edited CMakeFiles/openal.dir/link.txt and removed the soname stuff to get rid of a link problem involving libopenal.so.1)
$ make
$ make install (I think you might skip this)

copy $(NDK_ROOT)/sysroot/usr/lib/libRegal.so and opean-soft/build/libopenal.so in fs2open-android/jni/src

assuming there is a fs2open.gituhb.com antipodes along fs2open-android, go to fs2open.gitgub.com and do
$ git apply ../fs2open-android/android_patch_to_fs2open_antipodes.txt

then go back to fs2open-android and do:
$ ndk-build

this should build fs2open. If it fails and you have to tweak jni/src/Android.mk, I advise you to use this command to build instead of a simple ndk-build:
$ touch -r obj/local/armeabi-v7a/objs/main/__/__/__/fs2open.github.com/code/ai/ai.o jni/src/Android.mk && ndk-build
This will ensure that the build directory is not wiped out and no fully rebuilt...

Then to make the apk, install it and test:
$ android update project --name org.fs2open --path . --target android-23 --subprojects
$ ant debug
$ ant installd
$ adb shell am start -a fs2open.org.MAIN -n org.libsdl.app/org.libsdl.app.SDLActivity

It should crash on a c++ destructor unfortunately, so there is something wrong somewhere. I'm not knowledgeable enough to debug it efficiently, and I have no time left to do it, I hope that someone could try...

Hope I did not forget an important step.

Cheers,

s.

 

Offline chief1983

  • Still lacks a custom title
  • Moderator
  • 212
  • ⬇️⬆️⬅️⬅️🅰➡️⬇️
    • Minecraft
    • Skype
    • Steam
    • Twitter
    • Fate of the Galaxy
I applaud your efforts thus far, and appreciate you posting all this documentation.  I'm not sure many of the devs around here will be much help, without the ability to replicate the crash on this hardware.  However, if the crash is somehow related to graphics, it's probably something Regal doesn't like about our old code, which will be getting improved significantly as both m|m and Swifty have been making great strides in that area.
Fate of the Galaxy - Now Hiring!  Apply within | Diaspora | SCP Home | Collada Importer for PCS2
Karajorma's 'How to report bugs' | Mantis
#freespace | #scp-swc | #diaspora | #SCP | #hard-light on EsperNet

"You may not sell or otherwise commercially exploit the source or things you created based on the source." -- Excerpt from FSO license, for reference

Nuclear1:  Jesus Christ zack you're a little too hamyurger for HLP right now...
iamzack:  i dont have hamynerge i just want ptatoc hips D:
redsniper:  Platonic hips?!
iamzack:  lays

 
Thanks for your appreciation  :yes:

Here is the stack trace:
04-27 19:11:17.359   247   247 F DEBUG   :     #00 pc 00055a9a  /system/lib/libc.so (ifree+49)
04-27 19:11:17.359   247   247 F DEBUG   :     #01 pc 00058a17  /system/lib/libc.so (je_free+374)
04-27 19:11:17.360   247   247 F DEBUG   :     #02 pc 000fda04  /data/app/org.libsdl.app-1/lib/arm/libRegal.so (std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()+56)
04-27 19:11:17.360   247   247 F DEBUG   :     #03 pc 0023fdcf  /data/app/org.libsdl.app-1/lib/arm/libmain.so (GUIScreen::GUIScreen(std::string const&)+82)
04-27 19:11:17.360   247   247 F DEBUG   :     #04 pc 0023fe7b  /data/app/org.libsdl.app-1/lib/arm/libmain.so (GUISystem::GUISystem()+22)

unfortunately I do not have more information. I'm not sure it's even related to graphics, since it's a problem of a c++ std::string destructor that happens to occur in the windowing code.

[EDIT] fixed. well, actually it's because GUI_system is a global c++ object, and it seems android .so do not like that. 'don't know how many of them global objects there are...

I'm currently updating the procedure so it's easier to test it out... I saw a post on 'FSO on arm' which is actually on linux-on-shield, maybe someone from this project would be willing to give a try...
« Last Edit: April 27, 2016, 02:25:11 pm by stefanovic »

 
I reached a point where a dialog says something like "FreeSpace2/Fred2 cannot be run from a drive root directory!"
Well I guess these are good news actually  :)

I updated the tarball and included a README file. It should be easier to do now.

 
well, I struggled and struggled again, to no avail.
- I can't seem to open a working OpenAL device
- worst, I am not able to open an SDL OpenGL window with Regal.

Regal does work on my Shield TV, but it seems that SDL does not support it, see these posts:
https://github.com/p3/regal/issues/88
https://bugzilla.libsdl.org/show_bug.cgi?id=1613

There is no SDL_OPENGL_LIBRARY env variable anymore in SDL. On android, the file jni/SDL/src/render/opengl/SDL_render_gl.c  is compiled, but it's empty since SDL_VIDEO_RENDER_OGL is not defined for this platform. Toggling it makes it compile somehow (there is a problem with glBlendFuncSeparate), but I do not know how to make SDL choose this renderer when launched.  :banghead:

I'll stop for now on, I may get back to it later, but I already spent too much time on it...