user846316
user846316

Reputation: 6331

Support to 64-bit gives error on adding ndk.abiFilters in build.gradle

Most of the android developers must have got the message from Google to update the apps to support 64-bit architecture by Aug 2019. The detailed instructions are given here: Ensure that your app supports 64-bit devices

In my app, I found that the 32-bit libs are used and therefore I have to update the app to support 64-bit architecture. As suggested in the guide above, I added the following in build.gradle file:

ndk.abiFilters = 'armeabi-v7a' 'arm64-v8a' 'x86' 'x86_64'

However, after that, I get following error in building the app:

Error:(35, 0) Could not find method armeabi-v7a() for arguments [arm64-v8a] on DefaultConfig_Decorated{name=main, dimension=null, minSdkVersion=DefaultApiVersion{mApiLevel=16, mCodename='null'}, targetSdkVersion=DefaultApiVersion{mApiLevel=28, mCodename='null'}, renderscriptTargetApi=null, renderscriptSupportModeEnabled=null, renderscriptSupportModeBlasEnabled=null, renderscriptNdkModeEnabled=null, versionCode=3, versionName=1.2, applicationId=, testApplicationId=null, testInstrumentationRunner=null, testInstrumentationRunnerArguments={}, testHandleProfiling=null, testFunctionalTest=null, signingConfig=null, resConfig=null, mBuildConfigFields={}, mResValues={}, mProguardFiles=[], mConsumerProguardFiles=[], mManifestPlaceholders={}, mWearAppUnbundled=null} of type com.android.build.gradle.internal.dsl.DefaultConfig.

Has anybody already tried updating the app to 64-bit? Any idea, how to fix this issue?

Upvotes: 7

Views: 15716

Answers (5)

salman khan
salman khan

Reputation: 47

it works now

plugins {
        alias(libs.plugins.android.application)
        alias(libs.plugins.kotlin.android)
        alias(libs.plugins.google.gms.google.services)
        id("kotlin-kapt")
    }
    
    android {
        namespace = "com.ai.voice.voiceclone"
        compileSdk = 35
    
        defaultConfig {
            applicationId = "com.ai.voice.voiceclone"
            minSdk = 24
            targetSdk = 35
            versionCode = 1
            versionName = "1.0"
            testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
            ndk {
                abiFilters.add("armeabi-v7a")
                abiFilters.add("arm64-v8a")
                abiFilters.add("x86")
                abiFilters.add("x86_64")
            }
        }
    
        viewBinding {
            enable = true
        }
    
        buildTypes {
            release {
                isMinifyEnabled = false
                proguardFiles(
                    getDefaultProguardFile("proguard-android-optimize.txt"),
                    "proguard-rules.pro"
                )
            }
        }
    
        compileOptions {
            sourceCompatibility = JavaVersion.VERSION_1_8
            targetCompatibility = JavaVersion.VERSION_1_8
        }
    
        kotlinOptions {
            jvmTarget = "1.8"
        }
     
     
    }
    
    dependencies {
    
        implementation(libs.androidx.core.ktx)
        implementation(libs.androidx.appcompat)
        implementation(libs.material)
        implementation(libs.androidx.activity)
        implementation(libs.androidx.constraintlayout)
        implementation(libs.firebase.analytics)
        implementation(libs.firebase.database)
        implementation(libs.firebase.storage)
        testImplementation(libs.junit)
        androidTestImplementation(libs.androidx.junit)
        androidTestImplementation(libs.androidx.espresso.core)
        implementation("androidx.core:core-splashscreen:1.0.1")
    
        // SSP and SDP for responsive design
        implementation("com.intuit.sdp:sdp-android:1.1.1")
        implementation("com.intuit.ssp:ssp-android:1.1.1")
    
        // Lottie for animations
        implementation("com.airbnb.android:lottie:6.1.0")
     
    }

Upvotes: 0

Shubham Pandey
Shubham Pandey

Reputation: 209

For new android kotlin DSL you have to use this

android {
    ------
    ------

    defaultConfig {  

         ------
         ------  

       ndk {
            abiFilters.add("armeabi-v7a")
            abiFilters.add("x86_64")
            abiFilters.add("arm64-v8a")
        }
    }
}

Upvotes: 0

Rohan Pawar
Rohan Pawar

Reputation: 2003

For latest kotlin dsl

ndk {
     abiFilters.add("armeabi-v7a")
     abiFilters.add("arm64-v8a")
}

Upvotes: 4

Suryakant
Suryakant

Reputation: 190

It can be done by updating the build gradle defaultConfig

defaultConfig {
    applicationId "my.test.64bitapp"
    minSdkVersion 15
    targetSdkVersion 26
    versionCode 42
    versionName "1.0.2"
    multiDexEnabled true
    vectorDrawables.useSupportLibrary = true
    ndk.abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86' ,'x86_64'
}

or

defaultConfig {
    applicationId "com.swypmedia"
    minSdkVersion 16
    targetSdkVersion 26
    versionCode 2
    versionName "2.0.2"
    ndk {
        abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86' ,'x86_64'
    }
}

I have tested this on android-native and react-native app. build was successful and app was working.

Upvotes: 12

shizhen
shizhen

Reputation: 12573

According to NdkOptions, abiFilters is defined as Set<String>

Set<String> abiFilters

In groovy, Set is initialised using below syntax (if you want to use the operator '='):

Set<String> mySet = ["armeabi-v7a", "arm64-v8a", "x86", "x86_64"] 

Upvotes: 1

Related Questions