Skip to content

Add basic Android APK integration - #1001

Merged
Try merged 8 commits into
Try:masterfrom
Solessfir:android-build
Oct 7, 2026
Merged

Try merged 8 commits into
Try:masterfrom
Solessfir:android-build

Conversation

@Solessfir

@Solessfir Solessfir commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Adds a minimal ARM64 Android APK using Tempest's NativeActivity/Vulkan backend and add_android_apk helper. Depends on Try/Tempest#120 for native application-storage paths.

  • Build Gothic2Notr as a shared library; the APK target does not build Spacer.
  • Use the platform NativeActivity, with storage detection in InstallDetect instead of a Java/JNI bridge.
  • Read an ADB-provided Gothic II installation from app-specific external storage, without storage permissions. Keep saves and settings in internal storage.
  • Use Tempest logging for logcat output and collect Android stack traces using _Unwind_Backtrace and dladdr.
  • Add ARM64 native/APK compilation and Android lint to the existing GitHub workflow.

Build through the existing CMake project with the NDK toolchain, then run cmake --build build/android --target OpenGothic-apk. Build, installation and game-file copy commands are in android/README.md. No hand-maintained Gradle project is added.

Ray tracing and mesh shading are disabled in this initial build. Touch/controller input, importing, HDR and gameplay changes are separate follow-ups.

ARM64 release native compilation, APK assembly, Android lint and Windows Release compilation pass locally. This revised native-storage path has not been tested on a device yet. The earlier revision reached the Vulkan main menu on a Galaxy S24 but crashed on Home during Resources/VFS cleanup.

DmLoader_create fails with DmResult_MUTEX_ERROR: NDK 27 requires mtx_plain | mtx_recursive, whereas the pinned dependency passes only mtx_recursive. Its failure path leaves a dangling output pointer, which OpenGothic subsequently uses. The pointer-contract fix is pending in GothicKit/dmusic#14.

@Solessfir

Solessfir commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor Author

The 90-degree rotation is a related Tempest swapchain issue, not an OpenGothic menu issue. Fix submitted in Try/Tempest#119: use VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR when supported on Android, so presentation rotates the untransformed frame.

Comment thread android/java/org/opengothic/app/GothicActivity.java Outdated
Comment thread common/utils/crashlog.cpp Outdated
traceback.collect(0);
traceback.log(db, std::cout);
#elif defined(__LINUX__) || defined(__APPLE__)
#elif (defined(__LINUX__) && !defined(__ANDROID__)) || defined(__APPLE__)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, crash-logging wont work by look of this code?
That quite surprising, based that android still have compatibility with unix/linux

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The NDK lacks <execinfo.h> and backtrace. Android now uses _Unwind_Backtrace and dladdr, including module-relative addresses for offline symbolization.

Comment thread CMakeLists.txt Outdated
Comment thread README.md Outdated
Comment thread common/utils/crashlog.cpp
Comment thread common/utils/installdetect.cpp Outdated
Comment thread game/main.cpp Outdated
Tempest::Log::setOutputCallback([](Tempest::Log::Mode mode, const char* text) {
#if defined(__ANDROID__)
const int priority = mode==Tempest::Log::Error ? ANDROID_LOG_ERROR : mode==Tempest::Log::Debug ? ANDROID_LOG_DEBUG : ANDROID_LOG_INFO;
__android_log_write(priority,"OpenGothic",text);

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tempest::Log already implements __android_log_print, so application never really need to relay on OS-specific api

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the application-side Android logging call. Tempest::Log handles logcat output; the README now filters its app tag.

Comment thread CMakeLists.txt Outdated

# installation
install(TARGETS Gothic2Notr Spacer DESTINATION bin)
install(TARGETS Gothic2Notr DESTINATION bin)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this change has no effect

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Restored the single install(TARGETS Gothic2Notr Spacer DESTINATION bin) call.

@Try

Try commented Oct 5, 2026

Copy link
Copy Markdown
Owner

@Solessfir PR looks good - I'll need to find time to run/test it locally and then will merge (hopefully this week)

@Try

Try commented Oct 7, 2026

Copy link
Copy Markdown
Owner

Testing now, with clean install of android-studio (rabbit). There is apparently mistake in project generation: build.gradle almost enough, but then AS install incompatible version of gradle.
It seem we would need to also generate OpenGothic-apk/gradle/wrapper/gradle-wrapper.properties with hard-coded gradle version.
(can be different PR, PR's with submodules are quite a hassle)

@Try
Try merged commit ea77d87 into Try:master Oct 7, 2026
7 checks passed
@Try

Try commented Oct 7, 2026

Copy link
Copy Markdown
Owner

Merged, thanks!

And also I managed to get main menu running on emulator - cant wait to input support :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants