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
|
||||
Reference in New Issue
Block a user