How to add 64-bit and 32-bit native codes to an Android app?

Asked

Viewed 2,509 times

1

I’m having trouble publishing an app version. The Play store is notifying me about the new 32-bit and 64-bit architecture:

"This version does not comply with Google Play 64-bit requirement The following Apks or app packs are available for 64-bit devices. However, they only have 32-bit native codes: 22. Include native 64-bit and 32-bit codes in your app. Use the Android App Bundle publishing format to ensure that each device architecture automatically receives only the required native code. This will avoid increasing the overall size of your app. Learn more"

I followed the documentation steps, but still couldn’t add 64-bit support to my project code. Also I did not find much related beyond the official documentation.

Apparently they ask to add this line in gradew for those who use Android Studio:

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

But 64-bit library-supported folders are not yet generated by apk.

  • This configuration and the ones that are being presented in the responses, will only work if you are using the ANDROID_NDK to generate something with native code C/C++. -- If this is not your case, then you are probably using some third party framework that is not 64bit supported.

  • If you’re building builds with ANDROID_NDK, then maybe it’s worth it to add in your question the settings used in CMake or ndk-build, for the community to better understand your problem. -- To add more information click on [Edit] below your question.

2 answers

-2

Need to add in

 ndk {
            abiFilters "armeabi-v7a", "x86","arm64-v8a","x86_64"
        }
 abi {
            reset()
            enable enableSeparateBuildPerCPUArchitecture
            universalApk false  // If true, also generate a universal APK
            include "armeabi-v7a", "x86","arm64-v8a","x86_64"
        }
 def versionCodes = ["armeabi-v7a":1, "x86":2, "arm64-v8a":3,"x86_64":4 ]

That settled it here, I hope it helps you too

  • So where should I put this Abi{} and def versionCodes = ["armeabi-v7a":1, "x86":2, "arm64-v8a":3,"x86_64":4 ]? I tried it here, but it makes an error when synchronizing.

  • I’m using Android Studio. I was able to generate an apk without the libs, but I still could not generate with the 64 libs. Is there a command line that prevents this generation? or does this lib not have support for 64? I don’t know which library refers to "libImageProc.so" to search for in her documentation.

  • Where? Capable that I’ll have to abandon my app because of this, Google is kidding...

-2

import com.android.build.OutputFile

android {

defaultConfig {
    applicationId "com.package"
    minSdkVersion 21
    targetSdkVersion 29
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    signingConfig signingConfigs.config
    multiDexEnabled = true
    ndk {
        abiFilters 'armeabi-v7a', 'x86', 'arm64-v8a', 'x86_64'
    }
}
splits {
    density {
        enable true
        reset()
        include "mdpi", "hdpi"
    }
    abi {
        reset()
        // enable enableSeparateBuildPerCPUArchitecture
        universalApk false  // If true, also generate a universal APK
        include 'armeabi-v7a', 'x86', 'arm64-v8a', 'x86_64'
    }
}
ext.abiCodes = ['armeabi-v7a': 1, 'x86': 2, 'arm64-v8a': 3, 'x86_64': 4]
android.applicationVariants.all { variant ->
    variant.outputs.each { output ->
        def versionCodes = ['armeabi-v7a': 1, 'x86': 2, 'arm64-v8a': 3, 'x86_64': 4]
        def abi = output.getFilter(OutputFile.ABI)
        if (abi != null) {  // null for the universal-debug, universal-release variants
            output.versionCodeOverride =
                    versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
            }
        }
    }
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.