Files
questshock/android/app/build.gradle
T
2026-07-20 09:45:08 +02:00

89 lines
3.7 KiB
Groovy

apply plugin: 'com.android.application'
// Path to the (patched, at build time - see build-apk.sh and
// ../engine-patches/) scratch copy of engine/, written by build-apk.sh
// since it's only known at build time, not something a checked-in
// build.gradle can hardcode.
def engineProps = new Properties()
file("${projectDir}/../engine.properties").withInputStream { engineProps.load(it) }
def engineDir = engineProps.getProperty('engineDir')
if (engineDir == null) {
throw new GradleException("android/engine.properties is missing 'engineDir' - run via build-apk.sh, not gradlew directly")
}
android {
namespace "de.ladkau.questshock"
// compileSdk/buildToolsVersion/ndkVersion must all match what
// build-image/Dockerfile actually installs - otherwise AGP defaults to
// whatever version it itself prefers and tries to download it into the
// SDK dir at build time, which isn't writable.
compileSdk 34
buildToolsVersion "34.0.0"
ndkVersion "26.1.10909125"
defaultConfig {
applicationId "de.ladkau.questshock"
// 29, not compileSdk's 34, is deliberate - see build-image/Dockerfile's
// comment on ANDROID_PLATFORM_VERSION: paired with
// requestLegacyExternalStorage in the manifest, this keeps
// /sdcard/questshock/ a plain, unrestricted shared folder instead of
// Android 11+ scoped storage, on the Quest 2/3/3S/Pro headsets this
// targets - not just whatever's the current API level today.
minSdkVersion 24
targetSdkVersion 29
versionCode 1
versionName "1.0"
externalNativeBuild {
cmake {
// engine/CMakeLists.txt's own dependency-selection options
// (see engine/CMakeLists.txt near the top): SDL2 via
// find_package (our Android SDL2 build installs a real CMake
// config, unlike the desktop build's older bundled copy);
// SDL2_mixer and FluidSynth via the same build_ext/ BUNDLED
// convention the desktop build already uses (populated in the
// scratch engine copy by build-apk.sh from
// /opt/prebuilt/android/*).
// The CMAKE_FIND_ROOT_PATH* overrides below are needed
// because the NDK toolchain file restricts find_package/
// find_path/find_library to its own sysroot by default,
// which would otherwise miss our custom-installed SDL2 (see
// build-image/Dockerfile's SDL2_mixer build, which hit the
// exact same thing).
arguments "-DENABLE_SDL2=ON", "-DENABLE_SOUND=BUNDLED", "-DENABLE_FLUIDSYNTH=BUNDLED", \
"-DCMAKE_PREFIX_PATH=/opt/prebuilt/android/sdl2", \
"-DCMAKE_FIND_ROOT_PATH=/opt/prebuilt/android/sdl2", \
"-DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=BOTH", \
"-DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=BOTH", \
"-DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=BOTH", \
"-DANDROID_EXTRA_SOURCES=${projectDir}/src/main/cpp/questshock_native.c"
abiFilters 'arm64-v8a'
}
}
}
externalNativeBuild {
cmake {
path file("${engineDir}/CMakeLists.txt")
}
}
buildTypes {
release {
minifyEnabled false
}
}
lint {
abortOnError false
}
}
dependencies {
// ActivityCompat.checkSelfPermission/requestPermissions in
// QuestShockActivity - the plain android.app.Activity APIs work the
// same way without androidx, but ActivityCompat is the standard,
// documented way to request runtime permissions safely.
implementation 'androidx.core:core:1.12.0'
}