Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
295 changes: 159 additions & 136 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,136 +1,159 @@
plugins {
id "com.android.application"
}

android {
ndkVersion = '26.2.11394342'
compileSdk = 34
namespace = 'com.cxorz.anywhere'

signingConfigs {
debug {
storeFile rootProject.file('keystore/AnyWhere.jks')
storePassword 'AnyWhere'
keyAlias 'AnyWhereKey'
keyPassword 'AnyWhere'
}
release {
storeFile rootProject.file('keystore/AnyWhere.jks')
storePassword 'AnyWhere'
keyAlias 'AnyWhereKey'
keyPassword 'AnyWhere'
}
}

defaultConfig {
applicationId "com.cxorz.anywhere"
minSdkVersion 24
//noinspection ExpiredTargetSdkVersion
targetSdkVersion 34
versionCode 2018
versionName '2.1.8' // https://semver.org/lang/zh-CN/
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
resourceConfigurations += ['zh', 'zh-rCN', 'en', 'en-rUS']
ndk {
//noinspection ChromeOsAbiSupport
abiFilters "arm64-v8a"
}
signingConfig = signingConfigs.release
}

lint {
abortOnError = false
checkReleaseBuilds = false
}

buildTypes {
release {
// Enables code shrinking, obfuscation, and optimization for only
// your project's release build type.
minifyEnabled = true

// Enables resource shrinking, which is performed by the
// Android Gradle plugin.
shrinkResources = true

// Includes the default ProGuard rules files that are packaged with
// the Android Gradle plugin. To learn more, go to the section about
// R8 configuration files.
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

signingConfig = signingConfigs.release
multiDexEnabled = true
}
debug {
signingConfig = signingConfigs.debug
}
}

// 要存取 secret value 必須要使用到一個 BuildScript 的類別,默认会从 local.properties 中获取
buildFeatures {
buildConfig = true
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}

packagingOptions {
jniLibs {
excludes += ['lib/armeabi/**']
}
resources {
excludes += ['lib/armeabi/**']
}
}

sourceSets {
main {
jniLibs.srcDirs = ['libs']
}
}

dependenciesInfo {
includeInApk = false
includeInBundle = false
}

// 指定输出的可执行程序的名字
applicationVariants.configureEach { variant ->
variant.outputs.configureEach { output ->
def outputFile = output.outputFile
if (outputFile != null && outputFile.name.endsWith('.apk')) {
def fileName
if (variant.buildType.name == 'release') {
fileName = "AnyWhere_${defaultConfig.versionName}_arm64-v8a_release.apk"
} else {
fileName = "AnyWhere_${defaultConfig.versionName}_arm64-v8a_debug.apk"
}
outputFileName=fileName
}
}
}
}

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
// AppCompat 1.5.1 开始显式依赖于 Lifecycle 2.5.1 和 SavedState 1.2.0
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.2'
implementation 'androidx.appcompat:appcompat:1.7.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.preference:preference:1.2.1'
implementation 'com.google.android.material:material:1.12.0'
implementation 'com.squareup.okhttp3:okhttp:4.12.0'
implementation 'com.elvishew:xlog:1.11.1'
implementation 'io.noties.markwon:core:4.6.2'
implementation 'org.osmdroid:osmdroid-android:6.1.20'
implementation 'com.github.MKergall:osmbonuspack:6.9.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.3.0'
androidTestImplementation 'androidx.test:runner:1.7.0'
androidTestImplementation('androidx.test.espresso:espresso-core:3.7.0', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compileOnly 'de.robv.android.xposed:api:82'
}
plugins {
id "com.android.application"
}

android {
ndkVersion = '26.2.11394342'
compileSdk = 34
namespace = 'com.cxorz.anywhere'

signingConfigs {
debug {
storeFile rootProject.file('keystore/AnyWhere.jks')
storePassword 'AnyWhere'
keyAlias 'AnyWhereKey'
keyPassword 'AnyWhere'
}
release {
storeFile rootProject.file('keystore/AnyWhere.jks')
storePassword 'AnyWhere'
keyAlias 'AnyWhereKey'
keyPassword 'AnyWhere'
}
}

defaultConfig {
applicationId "com.cxorz.anywhere"
minSdkVersion 24
//noinspection ExpiredTargetSdkVersion
targetSdkVersion 34
versionCode 2018
versionName '2.1.8' // https://semver.org/lang/zh-CN/
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
resourceConfigurations += ['zh', 'zh-rCN', 'en', 'en-rUS']
ndk {
//noinspection ChromeOsAbiSupport
// 支持 arm64-v8a 与 armeabi-v7a,同时通过 splits 生成 universal APK
abiFilters "arm64-v8a", "armeabi-v7a"
}
signingConfig = signingConfigs.release
}

lint {
abortOnError = false
checkReleaseBuilds = false
}

buildTypes {
release {
// Enables code shrinking, obfuscation, and optimization for only
// your project's release build type.
minifyEnabled = true

// Enables resource shrinking, which is performed by the
// Android Gradle plugin.
shrinkResources = true

// Includes the default ProGuard rules files that are packaged with
// the Android Gradle plugin. To learn more, go to the section about
// R8 configuration files.
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

signingConfig = signingConfigs.release
multiDexEnabled = true
}
debug {
signingConfig = signingConfigs.debug
}
}

// 要存取 secret value 必須要使用到一個 BuildScript 的類別,默认会从 local.properties 中获取
buildFeatures {
buildConfig = true
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}

packagingOptions {
jniLibs {
excludes += ['lib/armeabi/**']
}
resources {
excludes += ['lib/armeabi/**']
}
}

sourceSets {
main {
jniLibs.srcDirs = ['libs']
}
}

dependenciesInfo {
includeInApk = false
includeInBundle = false
}

// 按 ABI 拆分 APK,并生成 universal APK(universalApk true)
splits {
abi {
enable true
reset()
include 'arm64-v8a', 'armeabi-v7a'
universalApk true
}
}

// 指定输出的可执行程序的名字(兼容按 ABI 拆分与 universal)
applicationVariants.configureEach { variant ->
variant.outputs.configureEach { output ->
def outputFile = output.outputFile
if (outputFile != null && outputFile.name.endsWith('.apk')) {
def abi = null
// 兼容不同 AGP 版本:尝试通过 API 读取 ABI 过滤器
try {
abi = output.getFilter(com.android.build.OutputFile.ABI)
} catch (ignored) {
// fallback: 某些 AGP 版本上 output.filters 可用
if (output.filters != null) {
def abiFilter = output.filters.find { it.filterType.name() == 'ABI' }
if (abiFilter != null) abi = abiFilter.identifier
}
}
def fileName
if (abi == null) {
// universal APK(无 ABI 过滤器)
fileName = "AnyWhere_${defaultConfig.versionName}_universal_${variant.buildType.name}.apk"
} else {
fileName = "AnyWhere_${defaultConfig.versionName}_${abi}_${variant.buildType.name}.apk"
}
outputFileName = fileName
}
}
}
}

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
// AppCompat 1.5.1 开始显式依赖于 Lifecycle 2.5.1 和 SavedState 1.2.0
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.2'
implementation 'androidx.appcompat:appcompat:1.7.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.preference:preference:1.2.1'
implementation 'com.google.android.material:material:1.12.0'
implementation 'com.squareup.okhttp3:okhttp:4.12.0'
implementation 'com.elvishew:xlog:1.11.1'
implementation 'io.noties.markwon:core:4.6.2'
implementation 'org.osmdroid:osmdroid-android:6.1.20'
implementation 'com.github.MKergall:osmbonuspack:6.9.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.3.0'
androidTestImplementation 'androidx.test:runner:1.7.0'
androidTestImplementation('androidx.test.espresso:espresso-core:3.7.0', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compileOnly 'de.robv.android.xposed:api:82'
}