| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211 |
- import java.nio.charset.StandardCharsets
- plugins {
- id 'com.android.application'
- }
- android {
- namespace "com.nonvioce.farm"
- ndkVersion '27.1.12297006'
- defaultConfig {
- applicationId project.properties["app.application_id"]
- versionCode project.properties["app.version_code"].toInteger()
- versionName project.properties["app.version_name"]
- minSdk 23
- compileSdk 35
- targetSdk 35
- externalNativeBuild {
- cmake {
- arguments "-DANDROID_STL=c++_shared", "-DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=1", "-DCMAKE_POLICY_VERSION_MINIMUM=3.5", "-DCMAKE_DISABLE_PRECOMPILE_HEADERS=ON", "-DCMAKE_BUILD_TYPE=RelWithDebInfo"
- // https://issuetracker.google.com/issues/274493986
- // Transitive shared library that's added through `add_dependencies` is not taken into
- // account. This result in liboboe.so and libluajit.so not get included into the final
- // APK. "love" target depends on LuaJIT, and "OpenAL" target depends on oboe::oboe
- // (which provides liboboe.so). So, add "OpenAL" and "love" target.
- targets "love_android", "OpenAL", "love"
- }
- }
- // 移除全局abiFilters,使用productFlavors为每个架构创建单独的构建
- ndk {
- //noinspection ChromeOsAbiSupport
- debugSymbolLevel 'full'
- }
- def getAppName = {
- def nameArray = project.properties["app.name_byte_array"]
- def name = project.properties["app.name"]
- if (name != null && nameArray != null) {
- throw new Exception("Only define either `app.name` or `app.name_byte_array` in gradle.properties, but not both!")
- }
- if (name == null) {
- def nameArraySplit = nameArray.split(",")
- def nameBytes = new byte[nameArraySplit.length]
- def count = 0
- for (String s: nameArraySplit) {
- nameBytes[count++] = (byte) Integer.parseInt(s)
- }
- return new String(nameBytes, StandardCharsets.UTF_8)
- }
- return name
- }
- manifestPlaceholders = [
- NAME:getAppName(),
- ORIENTATION:project.properties["app.orientation"],
- ]
- }
- def retrieveAll3pModules = { ->
- def modules = []
- // 遍历lua-modules目录,寻找包含Android.mk或CMakeLists.mk的目录
- def luaModulesDir = file("src/main/cpp/lua-modules/")
- if (luaModulesDir.exists() && luaModulesDir.isDirectory()) {
- luaModulesDir.eachFileRecurse { file ->
- if (file.isDirectory()) {
- def androidMk = file("${file.path}/Android.mk")
- def cmakeLists = file("${file.path}/CMakeLists.mk")
- if (androidMk.exists() || cmakeLists.exists()) {
- def logger = project.getLogger()
- logger.lifecycle("3rd-party module: ${file.path}")
- def javainfo = file("${file.path}/java.txt")
- if (javainfo.exists()) {
- def fstream = new FileInputStream(javainfo)
- def infile = new BufferedReader(new InputStreamReader(fstream))
- def javapath = infile.readLine().replace("\\", "/")
- def mpath = null
- if (javapath[0] != '/') {
- mpath = "${file.path}/${javapath}"
- } else {
- mpath = "${file.path}${javapath}"
- }
- modules << mpath
- logger.lifecycle("Registered path ${mpath}")
- infile.close()
- }
- }
- }
- }
- }
- return modules
- }
- buildTypes {
- release {
- minifyEnabled false
- proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
- }
- }
- buildFeatures {
- prefab true
- }
- flavorDimensions = ['mode', 'recording', 'architecture']
- productFlavors {
- normal {
- dimension 'mode'
- }
- embed {
- dimension 'mode'
- }
- record {
- dimension 'recording'
- }
- noRecord {
- dimension 'recording'
- }
- // 为每个架构创建单独的构建变体
- armeabiV7a {
- dimension 'architecture'
- ndk {
- abiFilters 'armeabi-v7a'
- }
- versionCode 101
- }
- arm64V8a {
- dimension 'architecture'
- ndk {
- abiFilters 'arm64-v8a'
- }
- versionCode 102
- }
- x86_64 {
- dimension 'architecture'
- ndk {
- abiFilters 'x86_64'
- }
- versionCode 103
- }
- }
- sourceSets {
- main {
- java {
- srcDir 'src/main/cpp/megasource/libs/SDL3/android-project/app/src/main/java'
- srcDir 'src/main/java'
- srcDir 'src/main/cpp/love/src/libraries/luahttps/src/android/java'
- srcDirs += retrieveAll3pModules()
- }
- }
- normal {
- java {
- srcDir 'src/normal/java'
- }
- }
- }
- compileOptions {
- sourceCompatibility JavaVersion.VERSION_1_8
- targetCompatibility JavaVersion.VERSION_1_8
- }
- buildFeatures {
- viewBinding true
- }
- externalNativeBuild {
- cmake {
- path file('src/main/cpp/CMakeLists.txt')
- // '+' notation apparently has been supported long time ago
- // https://issuetracker.google.com/issues/110693527#comment22
- // We require CMake 3.21 because r23 has important fixes
- // that's only fixed if CMake 3.21 is used.
- // https://github.com/android/ndk/issues/463
- version '3.21.0+'
- }
- }
- packagingOptions {
- jniLibs {
- excludes += [
- 'lib/armeabi-v7a/libOpenSLES.so',
- 'lib/arm64-v8a/libOpenSLES.so',
- 'lib/x86/libOpenSLES.so',
- 'lib/x86_64/libOpenSLES.so'
- ]
- }
- }
- }
- dependencies {
- implementation 'androidx.appcompat:appcompat:1.7.0'
- implementation 'com.google.android.material:material:1.12.0'
- implementation 'androidx.constraintlayout:constraintlayout:2.2.0'
- implementation 'androidx.navigation:navigation-fragment:2.8.5'
- implementation 'androidx.navigation:navigation-ui:2.8.5'
- implementation 'androidx.recyclerview:recyclerview:1.3.2'
- implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
- implementation 'com.google.oboe:oboe:1.9.3'
- }
- // We don't even use Kotlin. Why we have to care about it?
- configurations.implementation {
- exclude group: 'org.jetbrains.kotlin', module: 'kotlin-stdlib-jdk8'
- }
|