Skip to content

Processor Architecture Considerations

BlinkShelf is distributed with ARMv7 and ARM64 native library binaries.

ARMv7 architecture gives the ability to take advantage of hardware accelerated floating point operations and SIMD processing with NEON. This gives BlinkShelf a huge performance boost on devices that have ARMv7 processors. Most new devices (all since 2012.) have ARMv7 processor so it makes little sense not to take advantage of performance boosts that those processors can give. Also note that some devices with ARMv7 processors do not support NEON and VFPv4 instruction sets, most popular being those based on NVIDIA Tegra 2, ARM Cortex A9 and older. Since these devices are old by today’s standard, BlinkShelf does not support them. For the same reason, BlinkShelf does not support devices with ARMv5 (armeabi) architecture.

ARM64 is the new processor architecture that most new devices use. ARM64 processors are very powerful and also have the possibility to take advantage of new NEON64 SIMD instruction set to quickly process multiple pixels with a single instruction.

There are some issues to be considered:

  • ARMv7 build of the native library cannot be run on devices that do not have ARMv7 compatible processor
  • ARMv7 processors do not understand x86 instruction set
  • ARM64 processors understand ARMv7 instruction set, but ARMv7 processors do not understand ARM64 instructions.
    • NOTE: as of the year 2018, some android devices that ship with ARM64 processors do not have full compatibility with ARMv7. This is mostly due to incorrect configuration of Android’s 32-bit subsystem by the vendor, however Google decided that as of August 2019 all apps on PlayStore that contain native code need to have native support for 64-bit processors (this includes ARM64 and x86_64) - this is in anticipation of future Android devices that will support 64-bit code only, i.e. that will have ARM64 processors that do not understand ARMv7 instruction set.
  • if ARM64 processor executes ARMv7 code, it does not take advantage of modern NEON64 SIMD operations and does not take advantage of 64-bit registers it has - it runs in emulation mode

LibBlinkShelfCore.aar and LibBlinkShelfCameraUi.aar archives contain ARMv7 and ARM64 builds of the native library. By default, when you integrate BlinkShelf into your app, your app will contain native builds for all these processor architectures. Thus, BlinkShelf will work on ARMv7 and ARM64 devices and will use ARMv7 features on ARMv7 devices and ARM64 features on ARM64 devices. However, the size of your application will be rather large.

Reducing the final size of your app

We recommend that you distribute your app using App Bundle. This will defer apk generation to Google Play, allowing it to generate minimal APK for each specific device that downloads your app, including only required processor architecture support.

Using APK splits

If you are unable to use App Bundle, you can create multiple flavors of your app - one flavor for each architecture. With gradle and Android studio this is very easy - just add the following code to build.gradle file of your app:

android {
  ...
  splits {
    abi {
      enable true
      reset()
      include 'armeabi-v7a', 'arm64-v8a'
      universalApk true
    }
  }
}

With that build instructions, gradle will build two different APK files for your app. Each APK will contain only native library for one processor architecture and one APK will contain all architectures. In order for Google Play to accept multiple APKs of the same app, you need to ensure that each APK has different version code. This can easily be done by defining a version code prefix that is dependent on architecture and adding real version code number to it in following gradle script:

// map for the version code
def abiVersionCodes = ['armeabi-v7a':1, 'arm64-v8a':2]

import com.android.build.OutputFile

android.applicationVariants.all { variant ->
    // assign different version code for each output
    variant.outputs.each { output ->
        def filter = output.getFilter(OutputFile.ABI)
        if(filter != null) {
            output.versionCodeOverride = abiVersionCodes.get(output.getFilter(OutputFile.ABI)) * 1000000 + android.defaultConfig.versionCode
        }
    }
}

For more information about creating APK splits with gradle, check this article from Google.

After generating multiple APK’s, you need to upload them to Google Play. For tutorial and rules about uploading multiple APK’s to Google Play, please read the official Google article about multiple APKs.

Removing processor architecture support

If you won’t be distributing your app via Google Play or for some other reasons want to have single APK of smaller size, you can completely remove support for certain CPU architecture from your APK. This is not recommended due to consequences.

To keep only some CPU architectures, for example armeabi-v7a and arm64-v8a, add the following statement to your android block inside build.gradle:

android {
    ...
    ndk {
        // Tells Gradle to package the following ABIs into your application
        abiFilters 'armeabi-v7a', 'arm64-v8a'
    }
}

This will remove other architecture builds for all native libraries used by the application.

To remove support for a certain CPU architecture only for BlinkShelf, add the following statement to your android block inside build.gradle:

android {
    ...
    packagingOptions {
        exclude 'lib/<ABI>/libBlinkShelfCore.so'
        exclude 'lib/<ABI>/libBlinkShelfCameraUi.so'
    }
}

where <ABI> represents the CPU architecture you want to remove:

  • to remove ARMv7 support, use armeabi-v7a
  • to remove ARM64 support, use arm64-v8a.

You can also remove multiple processor architectures by specifying exclude directive multiple times. Just bear in mind that removing processor architecture will have side effects on performance and stability of your app. Please read this for more information.

Consequences of removing processor architecture

  • Google decided that as of August 2019 all apps on Google Play that contain native code need to have native support for 64-bit processors (this includes ARM64 and x86_64). This means that you cannot upload application to Google Play Console that supports only 32-bit ABI and does not support corresponding 64-bit ABI.

  • By removing ARMv7 support, BlinkShelf will not work on devices that have ARMv7 processors.

  • By removing ARM64 support, BlinkShelf will not use ARM64 features on ARM64 device
  • also, some future devices may ship with ARM64 processors that will not support ARMv7 instruction set.