Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 581
user846316 Avatar asked Feb 01 '19 09:02

user846316


Video Answer


2 Answers

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.

like image 178
Suryakant Avatar answered Oct 03 '22 03:10

Suryakant


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"] 
like image 35
shizhen Avatar answered Oct 03 '22 02:10

shizhen