#android #gradle #cmake #build #build.gradle
Вопрос:
У меня есть проект с двумя вариантами. В ci flavor я установил abiFilters только для сборки arm64-v8a abi. Я ожидаю, что при выполнении gradle assembleCiBuild --info
команды будет построено только приложение arm64-v8a. Но вместо этого в configureCMakeDebug (зависимость от assembleCiBuild) также настраивается x86 и создаются два приложения:
C/C : ${project_path}CMakeLists.txt ciDebug|arm64-v8a : Start JSON generation. Platform version: 16 min SDK version: arm64-v8a
C/C : ${project_path}CMakeLists.txt ciDebug|arm64-v8a : JSON '${project_path}.cxxDebug5b3t5u34arm64-v8aandroid_gradle_build.json' was up-to-date
C/C : ${project_path}CMakeLists.txt ciDebug|arm64-v8a : JSON generation completed without problems
C/C : ${project_path}CMakeLists.txt ciDebug|arm64-v8a : Writing build model to ${project_path}buildintermediatescxxDebug5b3t5u34metaarm64-v8abuild_model.json
C/C : ${project_path}CMakeLists.txt x86Debug|x86 : Start JSON generation. Platform version: 16 min SDK version: x86
C/C : ${project_path}CMakeLists.txt x86Debug|x86 : rebuilding JSON ${project_path}.cxxDebug5b3t5u34x86android_gradle_build.json due to:
C/C : ${project_path}CMakeLists.txt x86Debug|x86 : - expected json ${project_path}.cxxDebug5b3t5u34x86android_gradle_build.json file is not present, will remove stale json folder
C/C : ${project_path}CMakeLists.txt x86Debug|x86 : - missing previous command file ${project_path}.cxxDebug5b3t5u34x86metadata_generation_command.txt, will remove stale json folder
C/C : ${project_path}CMakeLists.txt x86Debug|x86 : - command changed from previous, will remove stale json folder
C/C : ${project_path}CMakeLists.txt x86Debug|x86 : removing stale contents from '${project_path}.cxxDebug5b3t5u34x86'
C/C : ${project_path}CMakeLists.txt x86Debug|x86 : created folder '${project_path}.cxxDebug5b3t5u34x86'
C/C : ${project_path}CMakeLists.txt x86Debug|x86 : executing cmake Executable : C:Program FilesCMakebincmake.exe
...
C/C : Build application_arm64-v8a
C/C : Executable : C:Program FilesCMakebinninja.exe
arguments :
-C
${project_path}.cxxDebug5b3t5u34arm64-v8a
application
jvmArgs :
...
C/C : Build application_x86
C/C : Executable : C:Program FilesCMakebinninja.exe
arguments :
-C
${project_path}.cxxDebug5b3t5u34x86
application
jvmArgs :
...
Не мог бы кто-нибудь, пожалуйста, сказать мне, что я делаю не так?
Вот мой файл build.gradle:
buildscript {
repositories {
google()
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.0.3'
classpath 'com.google.gms:google-services:4.3.10'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.7.1'
}
}
allprojects {
repositories {
google()
jcenter()
}
gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:deprecation"
}
}
}
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'
def keystorePropertiesFile = rootProject.file("keystore.properties")
def keystoreProperties = new Properties()
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
android {
packagingOptions {
doNotStrip "**/libapplication.so"
}
signingConfigs {
config {
storeFile file(keystoreProperties['storeFile'])
storePassword keystoreProperties['storePassword']
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
}
}
compileSdkVersion 29
defaultConfig {
applicationId "${id}"
minSdkVersion 16
targetSdkVersion 29
versionCode 1
versionName "0.1.0"
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
multiDexEnabled true
signingConfig signingConfigs.config
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.config
firebaseCrashlytics {
nativeSymbolUploadEnabled true
unstrippedNativeLibsDir file("build/intermediates/stripped_native_libs/arm64_v8aDebug/out/lib/arm64-v8a")
}
externalNativeBuild {
cmake {
arguments "-DANDROID_CPP_FEATURES=exceptions"
arguments "-DANDROID_PLATFORM=android-16"
arguments "-DANDROID_STL=c _static"
cppFlags "-std=c 17", "-Wno-c 98-compat", "-Wno-over-aligned", "-Wno-padded", "-Wno-override-module", "-O3", "-Wl,--build-id -g"
}
}
}
'assert' {
firebaseCrashlytics {
nativeSymbolUploadEnabled true
unstrippedNativeLibsDir file("build/intermediates/stripped_native_libs/arm64_v8aDebug/out/lib/arm64-v8a")
}
externalNativeBuild {
cmake {
arguments "-DANDROID_CPP_FEATURES=exceptions"
arguments "-DANDROID_PLATFORM=android-16"
arguments "-DANDROID_STL=c _static"
cppFlags "-std=c 17", "-Wno-c 98-compat", "-Wno-over-aligned", "-Wno-padded", "-Wno-override-module", "-O3", "-Wl,--build-id -g"
}
}
}
debug {
firebaseCrashlytics {
nativeSymbolUploadEnabled true
unstrippedNativeLibsDir file("build/intermediates/stripped_native_libs/arm64_v8aDebug/out/lib/arm64-v8a")
}
externalNativeBuild {
cmake {
arguments "-DANDROID_CPP_FEATURES=exceptions"
arguments "-DANDROID_PLATFORM=android-16"
arguments "-DANDROID_STL=c _static"
cppFlags "-std=c 17", "-Wno-c 98-compat", "-Wno-over-aligned", "-Wno-padded", "-Wno-override-module", "-O0", "-Wl,--build-id -g"
}
}
}
}
externalNativeBuild {
cmake {
path "CMakeLists.txt"
version '3.22.0'
}
}
flavorDimensions 'cpuArch'
productFlavors {
x86 {
dimension 'cpuArch'
externalNativeBuild {
cmake {
abiFilters 'x86', 'x86_64'
}
}
ndk {
abiFilters 'x86', 'x86_64'
}
}
ci {
dimension 'cpuArch'
externalNativeBuild {
cmake {
abiFilters 'arm64-v8a'
}
}
ndk {
abiFilters 'arm64-v8a'
}
}
}
compileOptions {
sourceCompatibility = 1.8
targetCompatibility = 1.8
}
ndkVersion '23.1.7779620'
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.facebook.android:facebook-android-sdk:[5,6)'
implementation 'com.google.android.gms:play-services-ads:18.2.0'
implementation 'com.google.android.gms:play-services-auth:18.1.0'
implementation 'com.android.billingclient:billing:3.0.0'
implementation 'com.google.android.play:core:1.8.0'
implementation 'com.google.ads.mediation:applovin:9.14.7.0'
implementation platform('com.google.firebase:firebase-bom:28.4.1')
implementation 'com.google.firebase:firebase-crashlytics-ndk'
implementation 'com.google.firebase:firebase-analytics'
implementation 'com.google.firebase:firebase-auth'
implementation 'com.google.firebase:firebase-firestore'
}