plugins { id 'com.android.application' id 'com.chaquo.python' } android { namespace 'com.maipulse.app' compileSdk 34 defaultConfig { applicationId "com.maipulse.app" minSdk 24 targetSdk 34 // 和网页里的 APP_VERSION 对齐,升级时一起改 versionCode 102 versionName "1.0.2" ndk { abiFilters "arm64-v8a" } // Chaquopy 16 的 DSL 挂在 android.defaultConfig 下面 python { buildPython "python" pip { install "flask" install "requests" install "pycryptodome" } } } // 固定 keystore:AGP 默认会在 $HOME/.android 下自动生成一个, // 而 zipalign 之后我们要用 apksigner 重签。两边不是同一个 key 的话, // 出来的包签名不一样,用户必须卸载才能覆盖安装。 signingConfigs { release { storeFile file("../maipulse-debug.keystore") storePassword "android" keyAlias "androiddebugkey" keyPassword "android" } debug { storeFile file("../maipulse-debug.keystore") storePassword "android" keyAlias "androiddebugkey" keyPassword "android" } } buildTypes { debug { signingConfig signingConfigs.debug } release { // 出正式包:关调试标志,开 R8 去死代码 + 混淆 Java 侧 signingConfig signingConfigs.release debuggable false minifyEnabled true shrinkResources true proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } } compileOptions { sourceCompatibility JavaVersion.VERSION_17 targetCompatibility JavaVersion.VERSION_17 } androidResources { // 这几类是已经压过的/要被 mmap 的,再压反而慢 noCompress 'json', 'png' } lint { // release 构建默认跑 lintVital,它会联网拉 lint-gradle 依赖。 // 这条链断了整包就出不来,而 lint 结果对发版没有决定意义,直接关掉。 checkReleaseBuilds false abortOnError false } packagingOptions { jniLibs { // 原生库直接从 APK 里 mmap,不再解压一份到 /data useLegacyPackaging = false } } } dependencies { implementation 'androidx.core:core:1.12.0' }