Can't build variant with specific abi using gradle

Viewed 279

I have a project with two flavors. In ci flavor I set abiFilters to only build arm64-v8a abi. I expect that when the gradle assembleCiBuild --info command is executed, only arm64-v8a apllication will be build. But instead, in configureCMakeDebug (dependency of assembleCiBuild) x86 is also being configured and the two applications are being built:

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}\.cxx\Debug\5b3t5u34\arm64-v8a\android_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}\build\intermediates\cxx\Debug\5b3t5u34\meta\arm64-v8a\build_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}\.cxx\Debug\5b3t5u34\x86\android_gradle_build.json due to:
C/C++: ${project_path}\CMakeLists.txt x86Debug|x86 : - expected json ${project_path}\.cxx\Debug\5b3t5u34\x86\android_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}\.cxx\Debug\5b3t5u34\x86\metadata_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}\.cxx\Debug\5b3t5u34\x86'
C/C++: ${project_path}\CMakeLists.txt x86Debug|x86 : created folder '${project_path}\.cxx\Debug\5b3t5u34\x86'
C/C++: ${project_path}\CMakeLists.txt x86Debug|x86 : executing cmake Executable : C:\Program Files\CMake\bin\cmake.exe
...

C/C++: Build application_arm64-v8a
C/C++: Executable : C:\Program Files\CMake\bin\ninja.exe
arguments : 
-C
${project_path}\.cxx\Debug\5b3t5u34\arm64-v8a
application
jvmArgs : 
...

C/C++: Build application_x86
C/C++: Executable : C:\Program Files\CMake\bin\ninja.exe
arguments : 
-C
${project_path}\.cxx\Debug\5b3t5u34\x86
application
jvmArgs : 
...

Could somebody please tell me, what I am doing wrong?

Here is my build.gradle file:

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'
}

0 Answers
Related