Android gradle : can't switch build varient with Active ABI - android

I am working on Android project whose build.gradle looks like this:
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
}
tasks.whenTaskAdded { task ->
if (task.name.contains("externalNativeBuild") || task.name.contains("buildCMake")) {
if(project.hasProperty("native")) {
//task.dependsOn(tasks.getByName("abc-all"))
tasks.getByName("abc-all").finalizedBy(task.name)
// xyz.finalizedBy(task.name)
} else {
//task.enabled = false
}
}
}
ant.importBuild 'build.xml'
android {
compileSdk 32
flavorDimensions "default","abi"
productFlavors {
devBuild {
dimension "default"
// This flavor is used to speed up the time required for building APKs
// In this intune is disabled. Only en and "xxhdpi" resources are bundled. and dynamically changing buildconfig value is made a constant.
resValue "bool", "isDevBuildVariant", "true"
resConfigs "en", "xxhdpi"
}
appCenter {
dimension "default"
}
fat {
dimension "abi"
ndk {
abiFilters "x86", "x86_64", "armeabi-v7a", "arm64-v8a"
}
}
armv7 {
dimension "abi"
ndk {
abiFilters "armeabi-v7a"
}
}
arm64 {
dimension "abi"
ndk {
abiFilters "arm64-v8a"
}
}
x86 {
dimension "abi"
ndk {
abiFilters "x86"
}
}
x86_64 {
dimension "abi"
ndk {
abiFilters "x86_64"
}
}
}
defaultConfig {
applicationId "com.example.myapplication"
minSdk 21
targetSdk 32
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
externalNativeBuild {
cmake {
arguments "--warn-uninitialized",
"-DANDROID_TOOLCHAIN=clang",
"-DANDROID_PLATFORM=android-21",
"-DSHARED_LIBRARY=1",
"-DOFFLINE_SYNC_SUPPORT_ENABLED=0"
}
}
}
buildTypes {
stage {
}
debug {
}
release {
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
externalNativeBuild {
cmake {
path file('src/main/cpp/CMakeLists.txt')
version '3.18.1'
}
}
buildFeatures {
viewBinding true
}
}
dependencies {
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.5.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
However the problem is I am unable to switch build varient in Android Studio.
I am able to switch from appCenterArm64Debug to appCenterFatDebug but not from appCenterArm64Debug to appCenterArmv7 or appCenterX86.
Looks like I am only able to change Active ABI from arm64-v8a to fat but not to any other ABI.
When I comment externalNativeBuild block inside android{}, the problem goes away but then I can't choose Active ABI.
Do I have add anything to gradle.

Related

unable to import paart-parslemouth in android

i am trying to install paart-parselmouth in android but unable to install I am getting the following error
How can I install it or how can I install its tar file?
Failed to install praat-parselmouth from https://files.pythonhosted.org/packages/a0/80/533a7330d7ed612628656f9aaee115076c578330039bc179c09fb8423251/praat-parselmouth-0.4.0.tar.gz.
here is my gradle
apply plugin: 'com.android.application'
apply plugin: 'com.chaquo.python'
android {
compileSdkVersion 28
buildToolsVersion "28.0.3"
defaultConfig {
applicationId "com.example.live_audio"
minSdkVersion 25
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
sourceSets {
main {
python {
srcDirs = ["src/main/python"]
}
}
}
python {
// buildPython "/usr/local/bin/python3"
// buildPython "python3"
pip {
install "praat-parselmouth"
install "numpy"
install "six"
}
}
ndk {
abiFilters "armeabi-v7a", "arm64-v8a", "x86", "x86_64"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}

Android spilts, different resources per abi

I'm trying to set up splits which should include different asset files for different abis.
However, when trying to run it on my x86 emulator, I get the following errors during build:
Cannot build selected target ABI: x86, no suitable splits configured: arm64-v8a;
Cannot build selected target ABI: x86, no suitable splits configured: armeabi-v7a;
Cannot build selected target ABI: x86, no suitable splits configured: x86_64;
My build.gradle looks like this:
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "org.mnemosyne"
minSdkVersion 21
targetSdkVersion 28
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
externalNativeBuild {
cmake {
arguments '-DANDROID_STL=c++_static'
}
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
flavorDimensions "abi"
productFlavors {
armeabi_v7a {
dimension "abi"
ndk.abiFilters 'armeabi-v7a'
}
arm64_v8a {
dimension "abi"
ndk.abiFilters 'arm64-v8a'
}
x86 {
dimension "abi"
ndk.abiFilters 'x86'
}
x86_64 {
dimension "abi"
ndk.abiFilters 'x86_64'
}
}
sourceSets {
armeabi_v7a {
jniLibs.srcDirs = ['../dependencies/python/lib/armeabi-v7a']
assets.srcDirs = ['../dependencies/python/lib/armeabi-v7a/',
'../dependencies/python/lib/armeabi-v7a/modules/']
}
arm64_v8a {
jniLibs.srcDirs = ['../dependencies/python/lib/arm64-v8a']
assets.srcDirs = ['../dependencies/python/lib/arm64-v8a/',
'../dependencies/python/lib/arm64-v8a/modules/']
}
x86 {
jniLibs.srcDirs = ['../dependencies/python/lib/x86']
assets.srcDirs = ['../dependencies/python/lib/x86/',
'../dependencies/python/lib/x86/modules/']
}
x86_64 {
jniLibs.srcDirs = ['../dependencies/python/lib/x86_64']
assets.srcDirs = ['../dependencies/python/lib/x86_64',
'../dependencies/python/lib/x86_64/modules/']
}
}
externalNativeBuild {
cmake {
version '3.10.2'
path 'src/main/cpp/CMakeLists.txt'
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.1.0'
}
}

Android NDK system mismatch - Android and Windows

I get this error in the CMakeOutput.log:
The target system is: Android - 1 - armv7-a
The host system is: Windows - 10.0.17134 - AMD64
when I try to build my project with NDK.
this is the build.gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "org.my.tester"
minSdkVersion 16
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
externalNativeBuild {
cmake {
cppFlags "-frtti -fexceptions -std=c++14"
arguments "-DANDROID_TOOLCHAIN=clang", "-DANDROID_STL=c++_shared"
}
ndk {
abiFilters 'armeabi-v7a'
}
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
externalNativeBuild {
cmake {
path "CMakeLists.txt"
}
}
sourceSets {
main {
jniLibs.srcDirs 'MySDK'
}
}
}
dependencies {
implementation fileTree(dir: 'MySDK', include: ['*.aar'])
implementation 'com.android.support:appcompat-v7:28.0.0-rc01'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

External native build issues, build command failed, error while executing 'C:/User/user.../cmake.exe' with arguments {-HF

Recently i have tried to attach cmake with my existing android studio project. I am searching SO since last four day not yet succeeded. Please don't mark this as duplicate. I am running android studio 2.2.1 with gradle version 2.14.1 in windows 8.1pro.
My build.gradle (app level):
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "25.0.2"
defaultConfig {
applicationId = "com.example.user.myproject"
minSdkVersion 17
targetSdkVersion 24
multiDexEnabled true
versionCode 1
versionName "1.0"
vectorDrawables.useSupportLibrary true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
externalNativeBuild {
cmake {
arguments '-DANDROID_TOOLCHAIN=clang'
}
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
// proguardFiles.add(file("proguard-rules.txt"))
}
}
externalNativeBuild {
cmake {
path 'src/main/cpp/CMakeLists.txt'
}
}
productFlavors {
arm7 {
// in the future, ndk.abiFilter might also work
ndk {
abiFilter 'armeabi-v7a'
}
}
arm8 {
ndk {
abiFilters 'arm64-v8a'
}
}
arm {
ndk {
abiFilter 'armeabi'
}
}
x86 {
ndk {
abiFilter 'x86'
}
}
x86_64 {
ndk {
abiFilter 'x86_64'
}
}
mips {
ndk {
abiFilters 'mips', 'mips64'
}
}
universal {
ndk {
abiFilters 'mips', 'mips64', 'x86', 'x86_64'
}
}
}
}
dependencies {
My CMakeLists.txt (path: 'app/src/main/cpp')
cmake_minimum_required(VERSION 3.4.1)
add_library(native-lib
SHARED
src/main/cpp/native-lib.cpp)
I am getting this error in message view:
Error while executing 'C:\Users\User\AppData\Local\Android\Sdk\cmake\3.6.4111459\bin\cmake.exe' with arguments {-HF:\MyProject\app\src\main\cpp -BF:\MyProject\app\.externalNativeBuild\cmake\x86_64Debug\x86_64 -GAndroid Gradle - Ninja -DANDROID_ABI=x86_64 -DANDROID_NDK=C:\Users\User\AppData\Local\Android\Sdk\ndk-bundle -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=F:\MyProject\app\build\intermediates\cmake\x86_64\debug\obj\x86_64 -DCMAKE_BUILD_TYPE=Debug -DCMAKE_MAKE_PROGRAM=C:\Users\User\AppData\Local\Android\Sdk\cmake\3.6.4111459\bin\ninja.exe -DCMAKE_TOOLCHAIN_FILE=C:\Users\User\AppData\Local\Android\Sdk\ndk-bundle\build\cmake\android.toolchain.cmake -DANDROID_NATIVE_API_LEVEL=21 -DANDROID_TOOLCHAIN=clang}
I don't know what's wrong here.

gradle dsl method not found: ' armv7a'

my build.grandle code is this one:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.example.assus.appweather"
minSdkVersion 19
targetSdkVersion 23
versionCode 1
versionName "1.0"
ndk {
moduleName = "odroid_weather"
abiFilter "x86"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets {
main {
jni.srcDirs = []
jniLibs.srcDirs 'main/src/libs'
}
}
productFlavors{
x86 {
ndk {
abiFilter "x86"
}
armv7a{
ndk {
abiFilter "armeabi-v7a"
}
}
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.2.1'
compile 'com.android.support:design:23.2.1'
}
and when I build my project, always this error is shown :
gradle dsl method not found: ' armv7a'
Gradle sync failed: Gradle DSL method not found: 'armv7a()'
Consult IDE log for more details (Help | Show Log)
some one can help me please !
Perhaps you meant to have a productFlavors that looks like this instead (it looks like you missing a closing brace):
productFlavors{
x86 {
ndk {
abiFilter "x86"
}
}
armv7a {
ndk {
abiFilter "armeabi-v7a"
}
}
}

Categories

Resources