Repository navigation
Add basic Android APK integration #1001
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
11c8721
ae55876
01dbdb1
714d4a0
aefda87
8351fde
388461a
e9b320d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
| <uses-feature android:name="android.hardware.vulkan.level" android:version="0" android:required="true" /> | ||
| <uses-feature android:name="android.hardware.vulkan.version" android:version="0x00401000" android:required="true" /> | ||
| <application android:label="OpenGothic" android:hasCode="false" android:allowBackup="false" | ||
| android:theme="@android:style/Theme.Material.NoActionBar.Fullscreen"> | ||
| <activity android:name="android.app.NativeActivity" android:exported="true" | ||
| android:screenOrientation="landscape" | ||
| android:configChanges="keyboard|keyboardHidden|navigation|orientation|screenSize|screenLayout|smallestScreenSize|density|uiMode"> | ||
| <meta-data android:name="android.app.lib_name" android:value="Gothic2Notr" /> | ||
| <intent-filter> | ||
| <action android:name="android.intent.action.MAIN" /> | ||
| <category android:name="android.intent.category.LAUNCHER" /> | ||
| </intent-filter> | ||
| </activity> | ||
| </application> | ||
| </manifest> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| # Android | ||
|
|
||
| An ARM64 NativeActivity APK using Tempest's Android backend and generated Gradle project. This is the basic platform integration; touch controls, controller input and game-file importing are not included yet. Android window destruction closes the application, including when backgrounding or locking destroys its surface. | ||
|
|
||
| ## Build | ||
|
|
||
| Install JDK 17, Gradle 8.9, CMake 3.22.1 or newer, Ninja and the Android SDK with SDK 35, build-tools 35.0.0, NDK 27.0.12077973 and SDK CMake 3.22.1. Set `JAVA_HOME`, `ANDROID_HOME` and `VULKAN_SDK`. Put Gradle, Ninja and the host Vulkan SDK's `glslangValidator` on `PATH`. Vulkan headers come from the host SDK; Android links the NDK's Vulkan loader. | ||
|
|
||
| Clone with `git clone --recursive https://github.com/Try/OpenGothic.git`, or run `git submodule update --init --recursive` in an existing checkout. Replace `/path/to/ndk` below with the NDK installation directory. The same commands work in PowerShell and a Linux shell. | ||
|
|
||
| ```sh | ||
| cmake -S . -B build/android -G Ninja -DCMAKE_TOOLCHAIN_FILE=/path/to/ndk/build/cmake/android.toolchain.cmake -DANDROID_ABI=arm64-v8a -DANDROID_PLATFORM=android-24 -DCMAKE_BUILD_TYPE=Release | ||
| cmake --build build/android --target OpenGothic-apk | ||
| ``` | ||
|
|
||
| APK: `build/android/OpenGothic-apk/build/outputs/apk/release/OpenGothic-apk-release.apk`. Use `-DCMAKE_BUILD_TYPE=Debug` for a debuggable APK under `outputs/apk/debug/OpenGothic-apk-debug.apk`. Desktop builds do not invoke the APK helper or require Android tools. | ||
|
|
||
| ## Install and game files | ||
|
|
||
| Use a legally owned Gothic II: Night of the Raven installation. No game files are included in the APK. Copy the installation root, not only its `Data` directory: `Data`, `_work` and `System` must be directly inside `Gothic2`. | ||
|
|
||
| ```sh | ||
| adb install -r build/android/OpenGothic-apk/build/outputs/apk/release/OpenGothic-apk-release.apk | ||
| adb shell mkdir -p /sdcard/Android/data/org.opengothic.app/files/Gothic2 | ||
| adb push "/path/to/Gothic II/." /sdcard/Android/data/org.opengothic.app/files/Gothic2/ | ||
| adb shell am start -n org.opengothic.app/android.app.NativeActivity | ||
| adb logcat -s OpenGothic AndroidRuntime DEBUG | ||
| ``` | ||
|
|
||
| Game files use app-specific external storage, without storage permissions. Logs, saves and writable settings use the app's internal files directory. Uninstalling removes both directories. Ray tracing and mesh shading are disabled for this initial Android build. | ||
|
|
||
| With a debug APK, read the file log using `adb shell run-as org.opengothic.app cat files/log.txt`. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,8 +14,13 @@ | |
| #include <Tempest/MetalApi> | ||
| #endif | ||
|
|
||
| #if defined(__IOS__) | ||
| #if defined(__IOS__) || defined(__ANDROID__) | ||
| #include "utils/installdetect.h" | ||
| #include <filesystem> | ||
| #endif | ||
|
|
||
| #if defined(__ANDROID__) | ||
| #include <android/log.h> | ||
| #endif | ||
|
|
||
| #include "utils/crashlog.h" | ||
|
|
@@ -68,7 +73,7 @@ std::unique_ptr<Tempest::AbstractGraphicsApi> mkApi(const CommandLine& g) { | |
| } | ||
|
|
||
| int main(int argc,const char** argv) { | ||
| #if defined(__IOS__) | ||
| #if defined(__IOS__) || defined(__ANDROID__) | ||
| { | ||
| auto appdir = InstallDetect::applicationSupportDirectory(); | ||
| std::filesystem::current_path(appdir); | ||
|
|
@@ -78,6 +83,10 @@ int main(int argc,const char** argv) { | |
| try { | ||
| static Tempest::WFile logFile("log.txt"); | ||
| 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); | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tempest::Log already implements
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed the application-side Android logging call. |
||
| #endif | ||
| logFile.write(text,std::strlen(text)); | ||
| logFile.write("\n",1); | ||
| if(mode==Tempest::Log::Error) | ||
|
|
||
| +1 −0 | Engine/gapi/metal/mtdevice.mm | |
| +2 −0 | Engine/gapi/vulkan/vswapchain.cpp | |
| +1 −0 | Engine/include/Tempest/AndroidApi | |
| +9 −0 | Engine/system/api/androidapi.cpp | |
| +5 −0 | Engine/system/api/androidapi.h |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.