android: complete the Gradle project and add build.sh
Move support/android to a top-level android/ and make it build: Gradle 8.12 wrapper + AGP 8.7.3, compileSdk/targetSdk 35, SDL3 3.4.16 and FreeType 2.13.3 built once into build/android-deps (SDL Java sources copied from the same release), libSDL3.so staged as a jniLib, 16 KB page alignment, RelWithDebInfo native code for debug APKs, placeholder adaptive icon. build.sh installs and launches the APK when a phone is attached. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
043881f032
commit
3ce5fc1a6c
@@ -0,0 +1,84 @@
|
||||
plugins {
|
||||
id 'com.android.application'
|
||||
}
|
||||
|
||||
// android/build.sh passes these; the defaults let Android Studio reuse what `build.sh deps` built.
|
||||
def repoRoot = file('../..').canonicalPath
|
||||
// AVA2_SOURCE_DIR builds another checkout/mirror of this repository (e.g. one with local SDK shims).
|
||||
def sourceDir = project.findProperty('AVA2_SOURCE_DIR') ?: repoRoot
|
||||
def depsPrefix = project.findProperty('AVA2_DEPS_PREFIX') ?: "${repoRoot}/build/android-deps/prefix-arm64-v8a"
|
||||
def sdlJava = project.findProperty('AVA2_SDL_JAVA') ?: "${repoRoot}/build/android-deps/sdl-java"
|
||||
def cmakeArgs = [
|
||||
"-DAVA2_BUILD_HOST=ON", "-DAVA2_EMBED_PYTHON=ON", "-DBUILD_TESTING=OFF",
|
||||
"-DANDROID_STL=c++_shared", "-DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON",
|
||||
"-DSDL3_DIR=${depsPrefix}/lib/cmake/SDL3", "-DCMAKE_FIND_ROOT_PATH=${depsPrefix}",
|
||||
]
|
||||
if (project.hasProperty('AVA2_SDK_ROOT')) cmakeArgs << "-DAVA2_SDK_ROOT=${project.property('AVA2_SDK_ROOT')}"
|
||||
|
||||
android {
|
||||
namespace 'com.metin2.ava2'
|
||||
compileSdk 35
|
||||
ndkVersion project.findProperty('AVA2_NDK_VERSION') ?: '27.2.12479018'
|
||||
|
||||
defaultConfig {
|
||||
applicationId "com.metin2.ava2"
|
||||
minSdk 26
|
||||
targetSdk 35
|
||||
versionCode 1
|
||||
versionName "0.1.0"
|
||||
|
||||
ndk {
|
||||
abiFilters 'arm64-v8a'
|
||||
}
|
||||
|
||||
externalNativeBuild {
|
||||
cmake {
|
||||
arguments(*cmakeArgs)
|
||||
targets 'main'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
}
|
||||
debug {
|
||||
debuggable true
|
||||
jniDebuggable true
|
||||
// Debug-built C++ is too slow to judge frame rate on a phone.
|
||||
externalNativeBuild { cmake { arguments "-DCMAKE_BUILD_TYPE=RelWithDebInfo" } }
|
||||
}
|
||||
}
|
||||
|
||||
externalNativeBuild {
|
||||
cmake {
|
||||
path file("${sourceDir}/CMakeLists.txt")
|
||||
version project.findProperty('AVA2_CMAKE_VERSION') ?: '3.22.1'
|
||||
}
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
main {
|
||||
java.srcDirs += [sdlJava]
|
||||
jniLibs.srcDirs += ["${depsPrefix}/lib-jni"]
|
||||
}
|
||||
}
|
||||
|
||||
packagingOptions {
|
||||
jniLibs {
|
||||
useLegacyPackaging = false
|
||||
}
|
||||
}
|
||||
|
||||
lint {
|
||||
abortOnError false
|
||||
}
|
||||
}
|
||||
|
||||
// libSDL3.so is a prebuilt dependency: stage it in the jniLibs layout AGP expects.
|
||||
tasks.register('stageSdlLibrary', Copy) {
|
||||
from "${depsPrefix}/lib/libSDL3.so"
|
||||
into "${depsPrefix}/lib-jni/arm64-v8a"
|
||||
}
|
||||
preBuild.dependsOn stageSdlLibrary
|
||||
@@ -0,0 +1,38 @@
|
||||
<?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:required="true" android:version="0" />
|
||||
<uses-feature android:name="android.hardware.touchscreen" android:required="false" />
|
||||
<uses-feature android:name="android.hardware.gamepad" android:required="false" />
|
||||
<uses-feature android:name="android.hardware.usb.host" android:required="false" />
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.VIBRATE" />
|
||||
|
||||
<application
|
||||
android:label="@string/app_name"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:allowBackup="false"
|
||||
android:appCategory="game"
|
||||
android:isGame="true"
|
||||
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
|
||||
android:enableOnBackInvokedCallback="false"
|
||||
android:hardwareAccelerated="true">
|
||||
|
||||
<activity
|
||||
android:name="org.libsdl.app.SDLActivity"
|
||||
android:label="@string/app_name"
|
||||
android:alwaysRetainTaskState="true"
|
||||
android:launchMode="singleInstance"
|
||||
android:screenOrientation="sensorLandscape"
|
||||
android:configChanges="layoutDirection|locale|grammaticalGender|fontScale|fontWeightAdjustment|orientation|uiMode|screenLayout|screenSize|smallestScreenSize|keyboard|keyboardHidden|navigation"
|
||||
android:preferMinimalPostProcessing="true"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
</manifest>
|
||||
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
|
||||
<solid android:color="#5A1A12" />
|
||||
</shape>
|
||||
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- "A" monogram inside the 72dp adaptive-icon safe zone. -->
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="108dp" android:height="108dp"
|
||||
android:viewportWidth="108" android:viewportHeight="108">
|
||||
<path android:fillColor="#E8C46A"
|
||||
android:pathData="M54,30 L74,78 L65,78 L60.5,66 L47.5,66 L43,78 L34,78 Z M50.3,58 L57.7,58 L54,47.5 Z" />
|
||||
</vector>
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Placeholder launcher icon until AVA2 artwork is chosen. -->
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@drawable/ic_launcher_background" />
|
||||
<foreground android:drawable="@drawable/ic_launcher_foreground" />
|
||||
</adaptive-icon>
|
||||
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="app_name">AVA2</string>
|
||||
</resources>
|
||||
Reference in New Issue
Block a user