/* * Copyright (c) 田梓萱[小草林] 2021-2024. * All Rights Reserved. * All codes are protected by China's regulations on the protection of computer software, and infringement must be investigated. * 版权所有 (c) 田梓萱[小草林] 2021-2024. * 所有代码均受中国《计算机软件保护条例》保护,侵权必究. */ @file:Suppress("UnstableApiUsage") import java.time.LocalDate import java.time.format.DateTimeFormatter.ofPattern import java.util.Properties plugins { id("com.android.application") id("com.didiglobal.booster") id("io.github.leavesczy.trace") id("com.google.devtools.ksp") id("androidx.room") id("kotlin-android") id("kotlin-parcelize") id("kotlinx-serialization") id("androidx.navigation.safeargs.kotlin") id("com.google.gms.google-services") id("com.google.firebase.firebase-perf") // id("com.google.firebase.crashlytics") id("version-catalog") id("io.sentry.android.gradle") id("io.sentry.kotlin.compiler.gradle") id("com.mikepenz.aboutlibraries.plugin") id("android.aop") } val properties = Properties() val isDebug = gradle.startParameter.taskNames.any { it.contains("debug", true) } properties.load(project.rootProject.file("gradle.properties").inputStream()) room { schemaDirectory("$projectDir/schemas") } android { namespace = "ink.xcl.saitra" compileSdk = 34 ndkVersion = "26.1.10909125" // compileSdkPreview = "UpsideDownCake" // flavorDimensions += listOf("arch") // productFlavors { // create("arm64") { // dimension = "arch" // ndk { // abiFilters += listOf("arm64-v8a") // 仅64位 // } // externalNativeBuild { // cmake { // cFlags += listOf("-Os -flto -ffunction-sections -fdata-sections -fvisibility=hidden") // abiFilters += listOf("arm64-v8a") // cppFlags += listOf("-Os -flto -ffunction-sections -fdata-sections // -fvisibility=hidden") // arguments += listOf("-Wl,--gc-sections", "-DANDROID_STL=c++_static") // } // } // } // create("arm32") { // dimension = "arch" // ndk { // abiFilters += listOf("armeabi-v7a") // 仅32位 // } // externalNativeBuild { // cmake { // cFlags += listOf("-Os -flto -ffunction-sections -fdata-sections -fvisibility=hidden") // abiFilters += listOf("armeabi-v7a") // cppFlags += listOf("-Os -flto -ffunction-sections -fdata-sections // -fvisibility=hidden") // arguments += listOf("-Wl,--gc-sections", "-DANDROID_STL=c++_static") // } // } // } // } lint { quiet = true ignoreWarnings = true abortOnError = false checkReleaseBuilds = true } experimentalProperties["android.experimental.art-profile-r8-rewriting"] = true experimentalProperties["android.experimental.r8.dex-startup-optimization"] = true defaultConfig { applicationId = "ink.xcl.saitra" multiDexEnabled = true ndk { abiFilters += listOf( "armeabi-v7a", // 兼容32位 "arm64-v8a", // 兼容64位 // "x86",//不兼容x86 // "x86_64",//不兼容x86_64 ) // 仅兼容64位 } minSdk = 22 targetSdk = 34 versionCode = LocalDate.now().format(ofPattern("yyyyMMdd")).toInt() versionName = "0.0.1" proguardFiles(getDefaultProguardFile("proguard-defaults.txt"), "proguard-rules.pro") multiDexKeepProguard = file("multidex-config.pro") testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" vectorDrawables { useSupportLibrary = true } // externalNativeBuild { // cmake { // cFlags += listOf("-Os -flto -ffunction-sections -fdata-sections -fvisibility=hidden") // abiFilters += listOf("armeabi-v7a", "arm64-v8a") // cppFlags += listOf("-Os -flto -ffunction-sections -fdata-sections -fvisibility=hidden") // arguments += listOf("-Wl,--gc-sections", "-DANDROID_STL=c++_static") // } // } } bundle { abi { // This property is set to true by default. enableSplit = true } } // signingConfigs { // // We use a bundled debug keystore, to allow debug builds from CI to be upgradable // create("release") { // storeFile = rootProject.file("./key/saitra.keystore") // storePassword = "2025Tzx." // keyAlias = "XCL_TZX_EI_AChatI" // keyPassword = "2025Tzx." // enableV1Signing = true // enableV2Signing = true // enableV3Signing = true // enableV4Signing = true // } // } composeOptions { kotlinCompilerExtensionVersion = libs.versions.composeCompiler.get() } packaging { // jniLibs { // excludes += "**/libchat.so" // }//动态加载-不合规-暂时移除 resources { excludes += "META-INF/DEPENDENCIES" excludes += "META-INF/NOTICE" excludes += "META-INF/LICENSE" excludes += "META-INF/LICENSE.txt" excludes += "META-INF/NOTICE.txt" excludes += "META-INF/LICENSE.md" excludes += "META-INF/LICENSE-notice.md" excludes += "META-INF/{AL2.0,LGPL2.1,LICENSE,NOTICE,DEPENDENCIES}" excludes += "DebugProbesKt.bin" excludes += "META-INF/*.kotlin_module" excludes += "**/*.kotlin_module" excludes += "**/*.version" } } buildTypes { debug { isDebuggable = true isCrunchPngs = true isJniDebuggable = true isMinifyEnabled = false isShrinkResources = false // signingConfig = signingConfigs.getByName("release") // versionNameSuffix = "-debug-${LocalDate.now().format(ofPattern("yyyy-MM-dd"))}" } release { isDebuggable = false isCrunchPngs = true isJniDebuggable = false isMinifyEnabled = true isShrinkResources = true // signingConfig = signingConfigs.getByName("release") // versionNameSuffix = "-release-${LocalDate.now().format(ofPattern("yyyy-MM-dd"))}" } // create("benchmark") { // signingConfig = signingConfigs.getByName("release") // matchingFallbacks += listOf("release") // isDebuggable = false // } } compileOptions { isCoreLibraryDesugaringEnabled = true sourceCompatibility = JavaVersion.VERSION_17 targetCompatibility = JavaVersion.VERSION_17 } kotlinOptions { jvmTarget = "17" val arguments = listOf( // https://kotlinlang.org/docs/compiler-reference.html#progressive "-progressive", // Enable Java default method generation. "-Xjvm-default=all", "-Xjsr305=strict", // Generate smaller bytecode by not generating runtime not-null assertions. "-Xno-call-assertions", "-Xno-param-assertions", "-Xno-receiver-assertions", ) freeCompilerArgs += arguments } splits { abi { isEnable = true reset() include("armeabi-v7a", "arm64-v8a") isUniversalApk = true } } buildFeatures { compose = true // dataBinding = false viewBinding = true buildConfig = true aidl = true } // externalNativeBuild { // cmake { // path = file("CMakeLists.txt") // version = "3.22.1" // } // } // 屏蔽 task (uploadCrashlyticsMappingFileRelease)-仅限国内构建、使用Mini打包不需要 // gradle.taskGraph.whenReady { // tasks.find { it.name == "uploadCrashlyticsMappingFileRelease" }?.enabled = false // } applicationVariants.all { outputs.all { if (this is com.android.build.gradle.internal.api.ApkVariantOutputImpl) { val filterData = getFilter(com.android.build.OutputFile.ABI) // println("EI_v${versionName}(${versionCode})_${filterData}_${buildType.name}.apk") outputFileName = if (filterData.isNullOrEmpty()) { "Tra_v${versionName}(${versionCode})_${buildType.name}.apk" } else { "Tra_v${versionName}(${versionCode})_(${filterData}|${buildType.name}).apk" } } } } sourceSets { getByName("main") { jniLibs.srcDir("libs") } } } aboutLibraries { // - `./gradlew app:exportLibraryDefinitions -PaboutLibraries.exportPath=src/main/res/raw` registerAndroidTasks = false outputFileName = "aboutlibraries.json" configPath = "config" offlineMode = false fetchRemoteLicense = true fetchRemoteFunding = true excludeFields = arrayOf("developers", "funding") includePlatform = true strictMode = com.mikepenz.aboutlibraries.plugin.StrictMode.WARN duplicationMode = com.mikepenz.aboutlibraries.plugin.DuplicateMode.MERGE duplicationRule = com.mikepenz.aboutlibraries.plugin.DuplicateRule.GROUP prettyPrint = true } dependencies { // implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar")))) implementation(libs.material) { exclude(group = "org.jetbrains.kotlin", module = "kotlin-bom") exclude(group = "androidx.activity", module = "activity") exclude(group = "androidx.appcompat", module = "appcompat") } implementation(libs.material3) implementation(libs.material3.adaptive) implementation(libs.material3.adaptive.navigation.suite) implementation(libs.material3.window.size) implementation(libs.androidx.foundation) implementation(libs.androidx.foundation.layout) implementation(libs.androidx.ui) implementation(libs.androidx.ui.util) implementation(libs.androidx.ui.graphics) debugImplementation(libs.androidx.ui.tooling) debugImplementation(libs.androidx.ui.tooling.preview) debugImplementation(libs.squareup.leakcanary) implementation(libs.androidx.material) implementation(libs.androidx.material.icons.core) implementation(libs.androidx.material.icons.extended) implementation(libs.androidx.runtime) implementation(libs.androidx.animation) implementation(libs.androidx.recyclerview) implementation(libs.androidx.recyclerview.selection) // androidTestImplementation(libs.androidx.runtime.tracing) // androidTestImplementation(libs.androidx.ui.test.manifest) // androidTestImplementation(libs.androidx.ui.test.junit4) implementation(libs.androidx.glance) implementation(libs.androidx.glance.appwidget) // implementation(libs.androidx.glance.material) implementation(libs.androidx.glance.material3) debugImplementation(libs.glance.appwidget.viewer) implementation(libs.glance.appwidget.host) implementation(libs.glance.appwidget.configuration) // implementation(libs.accompanist.permissions) implementation(libs.accompanist.navigation.material) { exclude(group = "androidx.navigation", module = "navigation-compose") } implementation(libs.accompanist.drawablepainter) implementation(libs.accompanist.adaptive) implementation(libs.androidx.navigation.ui.ktx) implementation(libs.androidx.navigation.compose) // androidTestImplementation(libs.androidx.navigation.testing) implementation(libs.androidx.window) implementation(libs.androidx.window.java) // androidTestImplementation(libs.androidx.window.testing) implementation(libs.androidx.lifecycle.viewmodel.ktx) implementation(libs.androidx.lifecycle.viewmodel.compose) implementation(libs.androidx.lifecycle.runtime.compose) implementation(libs.androidx.lifecycle.viewmodel.savedstate) implementation(libs.androidx.lifecycle.common.java8) implementation(libs.androidx.lifecycle.service) implementation(libs.androidx.lifecycle.process) implementation(libs.androidx.lifecycle.reactivestreams.ktx) implementation(libs.androidx.lifecycle.livedata.ktx) // androidTestImplementation(libs.androidx.core.testing) // androidTestImplementation(libs.androidx.lifecycle.runtime.testing) // room数据库 implementation(libs.androidx.room.runtime) // annotationProcessor(libs.androidx.room.compiler) ksp(libs.androidx.room.compiler) implementation(libs.androidx.room.ktx) implementation(libs.androidx.room.guava) // testImplementation(libs.androidx.room.testing) implementation(libs.sqlcipher.android) { exclude(group = "androidx.sqlite", module = "sqlite") } implementation(libs.androidx.sqlite) implementation(libs.androidx.sqlite.ktx) implementation(libs.androidx.sqlite.framework) // work implementation(libs.androidx.work.runtime.ktx) implementation(libs.androidx.work.gcm) // androidTestImplementation(libs.androidx.work.testing) implementation(libs.androidx.work.multiprocess) // sentry implementation(libs.sentry.android) implementation(libs.sentry.compose.android) implementation(libs.sentry.android.okhttp) { exclude(group = "com.squareup.okhttp3", module = "okhttp") } // implementation(libs.firebase.perf.ktx) // implementation(libs.firebase.crashlytics.ktx) // implementation(libs.firebase.crashlytics.ndk) // implementation(libs.firebase.config.ktx) // implementation(libs.firebase.analytics.ktx) // implementation(libs.firebase.messaging.ktx) // Ktor implementation(libs.ktor.client.core) implementation(libs.ktor.client.okhttp) { exclude(group = "com.squareup.okhttp3", module = "okhttp") } implementation(libs.ktor.client.logging) implementation(libs.ktor.client.content.negotiation) implementation(libs.ktor.client.encoding) implementation(libs.ktor.serialization.kotlinx.protobuf) // androidTestImplementation(libs.ktor.client.mock) // Okhttp implementation(libs.okhttp) implementation(libs.okhttp.sse) debugImplementation(libs.okhttp.monitor) releaseImplementation(libs.okhttp.monitor.noop) // Grpc // runtimeOnly(libs.grpc.okhttp) // api(libs.grpc.stub) // api(libs.grpc.protobuf.lite) // api(libs.grpc.kotlin.stub) // implementation(libs.protobuf.kotlinlite) // protobuf-kotlin解析 implementation(libs.kotlinx.serialization.protobuf) { exclude(group = "com.google.protobuf", module = "protobuf-javalite") } // protobuf-serialization解析 implementation(libs.protobuf.javalite) // protobuf-java解析 // 图片渲染-Coil implementation(libs.coil3) implementation(libs.coil3.compose) implementation(libs.coil3.gif) implementation(libs.coil3.svg) { exclude(group = "com.caverock", module = "androidsvg-aar") } implementation(libs.coil3.video) implementation(libs.coil3.network) { exclude(group = "com.squareup.okhttp3", module = "okhttp") } implementation(libs.zoomimage.compose.coil) implementation(libs.coil) implementation(libs.coil.compose) // Koin依赖注入 implementation(libs.koin.core) implementation(libs.koin.core.coroutines) implementation(libs.koin.android) implementation(libs.koin.android.compat) // implementation(libs.koin.androidx.workmanager) implementation(libs.koin.androidx.compose) implementation(libs.koin.androidx.compose.navigation) // androidTestImplementation(libs.koin.android.test) // androidTestImplementation(libs.androidx.tracing.perfetto) // androidTestImplementation(libs.androidx.tracing.perfetto.binary) implementation(libs.androidx.core) implementation(libs.androidx.core.google.shortcuts) implementation(libs.androidx.core.ktx) implementation(libs.androidx.core.animation) implementation(libs.androidx.core.performance) implementation(libs.androidx.core.splashscreen) implementation(libs.androidx.startup.runtime) implementation(libs.androidx.appcompat) { exclude(group = "androidx.fragment", module = "fragment") } implementation(libs.androidx.appcompat.resources) implementation(libs.androidx.emoji2) implementation(libs.androidx.emoji2.bundled) // implementation(libs.androidx.emoji2.emojipicker) // implementation(libs.androidx.gridlayout) // implementation(libs.billing.ktx) // implementation(libs.alipaysdk.android)//应用内支付-支付宝-暂时移除 implementation(libs.androidx.activity.ktx) implementation(libs.androidx.activity.compose) implementation(libs.annotation) implementation(libs.androidx.concurrent.futures.ktx) implementation(libs.androidx.annotation.experimental) implementation(libs.androidx.constraintlayout) implementation(libs.androidx.constraintlayout.compose) implementation(libs.androidx.asynclayoutinflater) implementation(libs.androidx.collection.ktx) // exoplayer implementation(libs.media3.exoplayer) // agora implementation(libs.agora.rtc.basic) // implementation(libs.material) implementation(libs.androidx.multidex) coreLibraryDesugaring(libs.desugar.jdk.libs) implementation(libs.bcprov.jdk15on) implementation(libs.relinker) implementation(libs.guava) // implementation(libs.lottie.compose) // AE动画 implementation(libs.androidx.transition.ktx) // 协程 implementation(libs.kotlinx.coroutines.core) implementation(libs.kotlinx.coroutines.play.services) implementation(libs.kotlinx.coroutines.android) implementation(libs.kotlin.reflect) implementation(libs.kotlin.stdlib) implementation(libs.kotlin.stdlib.jdk7) implementation(libs.kotlin.stdlib.jdk8) // androidTestImplementation(libs.kotlinx.coroutines.test) // androidTestImplementation(libs.androidx.junit) // androidTestImplementation(libs.androidx.espresso.core) // testImplementation(libs.junit.jupiter.api) // androidTestImplementation(libs.junit.jupiter.api) // Acra 异常全局捕获 implementation(libs.acra.core) implementation(libs.acra.toast) implementation(libs.acra.advanced.scheduler) implementation(libs.auto.service.annotations) ksp(libs.auto.service.ksp) implementation(libs.androidx.fragment) // GMS implementation(libs.play.services.location) // implementation(libs.integrity) // TODO:暂时取消掉翻译的依赖 // implementation(libs.playstore.dynamic.feature.support) // { // exclude(group = "com.google.android.play", module = "core") // } // implementation(libs.translate)//文本翻译 // Play Core implementation(libs.asset.delivery.ktx) implementation(libs.feature.delivery.ktx) // implementation(libs.review.ktx) implementation(libs.app.update.ktx) implementation(libs.android.aop.core) implementation(libs.android.aop.annotation) ksp(libs.android.aop.ksp) implementation(libs.aboutlibraries.core) implementation(libs.aboutlibraries.compose.m3) // QrCode // implementation(libs.qrose) // 拼音 // implementation(libs.pinyin4j) // profile优化 implementation(libs.androidx.profileinstaller) } configurations.all { resolutionStrategy.cacheChangingModulesFor(10, TimeUnit.SECONDS) }