How to make Android apps which support both 32-bit and 64-bit architecture?

by JorgeAmVF   Last Updated July 12, 2019 14:26 PM - source

I've just received and read a newsletter from Google Play mentioning that from next year on, the store "will require that new apps and app updates with native libraries provide 64-bit versions in addition to their 32-bit versions".

For those who haven't read it yet, it states:

64-bit support requirement in 2019

Platform support for 64-bit architectures was introduced in Android 5.0. Today, over 40% of Android devices coming online have 64-bit support, while still maintaining 32-bit compatibility. For apps that use native libraries, 64-bit code typically offers significantly better performance, with additional registers and new instructions.

In anticipation of future Android devices that support 64-bit code only, the Play Console will require that new apps and app updates with native libraries provide 64-bit versions in addition to their 32-bit versions. This can be within a single APK or as one of the multiple APKs published.

We are not removing 32-bit support. Google Play will continue to support 32-bit apps and devices. Apps that do not include native code are unaffected.

This change will come into effect in August 2019. We're providing advance notice today to allow plenty of time for developers who don't yet support 64-bit to plan the transition. Stay tuned for a future post in which we'll take an in-depth look at the performance benefits of 64-bit native libraries on Android, and check out the CPUs and Architectures guide of the NDK for more info.

What practical changes will we need to make to perfectly comply with this new requirement when applicable?



Answers 5


If you have no native (NDK) code, that is you only write Java/Dex code, then you don't need to do anything.

If you have native code (or libraries) then you need to supply their 64-bit versions.

Nick Fortescue
Nick Fortescue
February 02, 2018 16:05 PM

According to an official email sent by the Google Play Team, the action required is:

If you haven't yet, we encourage you to begin work for the 64-bit requirement as soon as possible. Many apps are written entirely in non-native code (e.g. the Java programming language or Kotlin) and will not need code changes.

Please note that we are not making changes to our policy on 32-bit support. Google Play will continue to deliver apps with 32-bit native code to 32-bit devices. The requirement means that those apps will need to have a 64-bit version as well.

To help you make the transition, we've prepared documentation on how to check whether your app already supports 64-bit and how to become 64-bit compliant.

We're also providing a high-level timeline below.

So, the linked documentation explains:

If your app uses only code written in the Java programming language or Kotlin, including any libraries or SDKs, your app is already ready for 64-bit devices. If your app uses any native code, or you are unsure if it does, you will need to assess your app and take action.

[...]

The simplest way to check for 64-bit libraries is to inspect the structure of your APK file. When built, the APK will be packaged with any native libraries needed by the app. Native libraries are stored in various folders based on the ABI. It is not required to support every 64-bit architecture, but for each native 32-bit architecture you support you must include the corresponding 64-bit architecture.

For the ARM architecture, the 32-bit libraries are located in armeabi-v7a. The 64-bit equivalent is arm64-v8a.

For the x86 architecture, look for x86 for 32-bit and x86_64 for 64-bit.

The first thing to do is ensure that you have native libraries in both of these folders.[...]

And, to build 64-bit libraries, you basically need to follow the instructions below:

Most Android Studio projects use Gradle as the underlying build system, so this section applies to both cases. Enabling builds for your native code is as simple as adding the arm64-v8a and/or x86_64, depending on the architecture(s) you wish to support, to the ndk.abiFilters setting in your app's 'build.gradle' file:

// Your app's build.gradle
apply plugin: 'com.android.app'

android {
   compileSdkVersion 27
   defaultConfig {
       appId "com.google.example.64bit"
       minSdkVersion 15
       targetSdkVersion 28
       versionCode 1
       versionName "1.0"
       ndk.abiFilters 'armeabi-v7a' 'arm64-v8a' 'x86' 'x86_64'
// ...

Finally, a quick note:

The 64-bit version of your app should offer the same quality and feature set as the 32-bit version.

JorgeAmVF
JorgeAmVF
February 01, 2019 06:57 AM

As per documentation here, if your app is using native code or external library, for example, realm (in the picture below) which is based on native, then a support for 64-bit should be provided. If any of external libraries in your app which uses any C/C++ (native) should have both 32-bit and 64-bit architecture support otherwise you should make contact with the library owner. In Android Studio, we can check whether versions for both architectures are available by Build > Analyze APK and the following window appears:

Android Studio tab showing avaiable architectures

If you are using NDK and creating native code, you should provide support for both architecture by enlisting them in the gradle as:

defaultConfig {  
   ndk.abiFilters = 'armeabi-v7a' 'arm64-v8a' 'x86' 'x86_64'
   }
Irfan Ul Haq
Irfan Ul Haq
March 05, 2019 11:11 AM

Native code: refers to an executable program that was compiled directly to the CPU instructions of the computer it is running on.

Non-native code: refers to an executable program that was compiled to the CPU instructions of the original Tandem architecture of the late 1970s and 1980s. When such a program is run, it cannot execute directly on the CPU of the computer it is running on. The NonStop operating system includes an interpreter for that original Tandem architecture, which is used to run such non-native code.

If your app uses only code written in the Java programming language or Kotlin, including any libraries or SDKs, your app is already ready for 64-bit devices. If your app uses any native code, or you are unsure if it does, you will need to assess your app and take action.

Does your app use native code?

The first thing to do is to check to see if your app uses any native code. Your app makes use of native code if it:

  • uses any C/C++ (native) code in your app.
  • links with any third party native libraries;
  • is built by a third party app builder that uses native libraries.

For more, visit the docs.

EL TEGANI MOHAMED
EL TEGANI MOHAMED
July 04, 2019 16:16 PM

If your android apk is not including 64 bit support, you need not to worry. Go to Build -> Analyze APK, in android studio. You can able to see apk structure. Under lib if you see armeabi-v7a libraries and if you do not have any arm64-v8a or x86_64 libraries, then your apk is not 64 bit support.

Just go to app level build.gradle and add abiFilters in ndk under defaultConfig as below :

ndk {
    abiFilters 'armeabi-v7a','arm64-v8a','x86','x86_64'
}
sagarchavan
sagarchavan
July 11, 2019 11:37 AM

Related Questions




cannot upgrade google play services

Updated June 23, 2015 03:11 AM

updating Google play services in Emulator

Updated February 27, 2017 06:26 AM