Compile Open-Source Game as APK file; Write Instructions for Doing So
New here? Learn about Bountify and follow @bountify to get notified of new bounties! x

I am the Lead Developer for a complex, cross-platform strategy game. Note that the T820 feature branch should be treated as the most up-to-date Development branch, as I still have yet to merge it into master. (Sue me.)

I have gotten the game to build on GNU/Linux and (with much effort) on Windows. I am also familiar with the process of building static libraries for SDL, SDL_image, and so forth. However, every time I try to run the scripts for building a SDL test program for Android, I run into errors.

In order to earn the bounty:

  1. compile this game for Android and send the APK file;
  2. write instructions (as clear and complete as possible) for how I can compile the game from a Linux build environment;
  3. if you want to go above and beyond (and earn a $25 tip if I can figure out how to do this), be the first person to modify the source code in order to rotate the graphics & input handling 90° clockwise in order to turn the UI from "Portrait" to "Landscape," which I expect to be much neater and more convenient on the screen dimensions of a phone.

Relevant Documentation

What I Have Tried So Far

Method 1: Trying to Build SDL2's Basic Test

Upon reviewing the chat logs, I find that at one point in April 2020, I said to my developer friend:

I guess I shouldn't be compiling the SDL libraries themselves

And he replied:

yeah - at least not manually, you can just run the command from the wiki (i think the script is called androidbuild or something like that), that compiles the necessary things for you (and tells you how to androidify it)

Sure enough, SDL's README-android suggests that I can simply enter ./androidbuild.sh org.libsdl.testgles ../test/testgles.c in order to build a basic SDL test for Android.

But this doesn't actually run any build; rather, it directs you to run a different command in order to run a build.

"I can help you with that! Allow me to direct you to someone who can help you with that!"

./gradlew installDebug

But this build fails, with a very lengthy and unclear stacktrace (with numerous "org.gradle.launcher" lines, etc.). So I have to scroll all the way up and see this debugging line:

18:23:34.036 [WARN] [com.android.build.gradle.internal.ndk.NdkHandler] NDK is missing a "platforms" directory.
If you are using NDK, verify the ndk.dir is set to a valid NDK directory.  It is currently set to /home/chozorho/misc/Android/android-studio.
If you are not using NDK, unset the NDK variable from ANDROID_NDK_HOME or local.properties to remove this warning.

I try changing the ANDROID_NDK_HOME, but the same general error arises.
Other people have had the same problem, and the only way to solve it is to use an older version of the installed NDK. Ok, fine.

export ANDROID_NDK_HOME=/home/chozorho/Android/Sdk/ndk/21.4.7075529/

But now I get a compilation error looking like:

20:13:05.325 [LIFECYCLE] [org.gradle.api.Project] [x86_64] Compile        : SDL2 <= SDL_dataqueue.c
20:13:05.682 [LIFECYCLE] [org.gradle.api.Project] [x86_64] Compile        : SDL2 <= SDL_hints.c
20:13:05.722 [LIFECYCLE] [org.gradle.api.Project] [x86_64] Compile        : SDL2 <= SDL.c
20:13:05.998 [LIFECYCLE] [org.gradle.api.Project] In file included from /home/chozorho/misc/SDL2/SDL2-2.0.14/build/org.libsdl.testgles/app/jni/SDL/src/SDL.c:47:
20:13:05.998 [LIFECYCLE] [org.gradle.api.Project] In file included from /home/chozorho/misc/SDL2/SDL2-2.0.14/build/org.libsdl.testgles/app/jni/SDL/src/events/SDL_events_c.h:30:
20:13:05.998 [LIFECYCLE] [org.gradle.api.Project] In file included from /home/chozorho/misc/SDL2/SDL2-2.0.14/build/org.libsdl.testgles/app/jni/SDL/src/events/../video/SDL_sysvideo.h:31:
20:13:05.998 [LIFECYCLE] [org.gradle.api.Project] In file included from /home/chozorho/misc/SDL2/SDL2-2.0.14/build/org.libsdl.testgles/app/jni/SDL/src/events/../video/SDL_vulkan_internal.h:49:
20:13:05.998 [LIFECYCLE] [org.gradle.api.Project] /home/chozorho/misc/SDL2/SDL2-2.0.14/build/org.libsdl.testgles/app/jni/SDL/src/events/../video/wayland/SDL_waylanddyn.h:38:10: fatal error: 'wayland-cursor.h' file not found
20:13:05.998 [LIFECYCLE] [org.gradle.api.Project] #include "wayland-cursor.h"
20:13:05.998 [LIFECYCLE] [org.gradle.api.Project]          ^~~~~~~~~~~~~~~~~~
20:13:06.036 [LIFECYCLE] [org.gradle.api.Project] 1 error generated.
20:13:06.039 [LIFECYCLE] [org.gradle.api.Project] make: *** [/home/chozorho/Android/Sdk/ndk/21.4.7075529/build/core/build-binary.mk:476: /home/chozorho/misc/SDL2/SDL2-2.0.14/build/org.libsdl.testgles/app/build/intermediates/ndkBuild/debug/obj/local/x86_64/objs-debug/SDL2/src/SDL.o] Error 1
20:13:06.041 [DEBUG] [org.gradle.process.internal.DefaultExecHandle] Changing state to: FAILED
20:13:06.041 [DEBUG] [org.gradle.process.internal.DefaultExecHandle] Process 'command '/home/chozorho/Android/Sdk/ndk/21.4.7075529/ndk-build'' finished with exit value 2 (state: FAILED)

By re-configuring and rebuilding the SDL libraries, then I can advance beyond this point, but then I get to another missing header file:

Build command failed.
  Error while executing process /home/chozorho/Android/Sdk/ndk/21.4.7075529/ndk-build with arguments {NDK_PROJECT_PATH=null APP_BUILD_SCRIPT=/home/chozorho/misc/SDL2/SDL2-2.0.14/build/org.libsdl.testgles/app/jni/Android.mk NDK_APPLICATION_MK=/home/chozorho/misc/SDL2/SDL2-2.0.14/build/org.libsdl.testgles/app/jni/Application.mk APP_ABI=x86_64 NDK_ALL_ABIS=x86_64 NDK_DEBUG=1 APP_PLATFORM=android-16 NDK_OUT=/home/chozorho/misc/SDL2/SDL2-2.0.14/build/org.libsdl.testgles/app/build/intermediates/ndkBuild/debug/obj NDK_LIBS_OUT=/home/chozorho/misc/SDL2/SDL2-2.0.14/build/org.libsdl.testgles/app/build/intermediates/ndkBuild/debug/lib APP_PLATFORM=android-16 /home/chozorho/misc/SDL2/SDL2-2.0.14/build/org.libsdl.testgles/app/build/intermediates/ndkBuild/debug/obj/local/x86_64/libSDL2.so}
  [x86_64] Compile        : SDL2 <= SDL_wave.c
  In file included from /home/chozorho/misc/SDL2/SDL2-2.0.14/build/org.libsdl.testgles/app/jni/SDL/src/audio/SDL_wave.c:39:
  /home/chozorho/misc/SDL2/SDL2-2.0.14/build/org.libsdl.testgles/app/jni/SDL/src/audio/SDL_audio_c.h:40:10: fatal error: 'samplerate.h' file not found
  #include "samplerate.h"
           ^~~~~~~~~~~~~~
  1 error generated.
  make: *** [/home/chozorho/Android/Sdk/ndk/21.4.7075529/build/core/build-binary.mk:476: /home/chozorho/misc/SDL2/SDL2-2.0.14/build/org.libsdl.testgles/app/build/intermediates/ndkBuild/debug/obj/local/x86_64/objs-debug/SDL2/src/audio/SDL_wave.o] Error 1

This doesn't make any sense, because the file build/org.libsdl.testgles/app/jni/SDL/Android.mk includes the line

LOCAL_C_INCLUDES := /usr/include

which contains the file samplerate.h.

In short, none of the build process is making sense to me -- and this is simply when I try to compile the example SDL project! Imagine how much more difficult it will be to build my source files.

Method 2: C4Droid

Alternatively, I try installing the C4Droid app with the SDL plugin. I apply a crazy shortcut bodge (namely, using #include statements to cover all .c files into the same central .c file to be compiled), but the compilation does not go anywhere: instead, the system just pauses for several seconds and then terminates with a black screen, possible due to memory constraints or some other failure. Suffice it to say, this didn't work either.

Any help would be well-appreciated. If you have questions, feel free to contact me.

allLogarithmsEqual@protonmail.com

GitHub

3 months ago

Crowdsource coding tasks.

0 Solutions