4

After adding openCV 3.0 as library in Android Studio, I observed my apk file has grown to above 50MB, which is obviously not ideal.

Unzipping the apk file revealed that there are multiple target architectures in the lib directory, namely arm64-v8a, armeabi, armeabi-v7a, mips, mips64, x86, x86_64. Each of them occupies 10+MB.

Is it safe to remove some of the target architectures from my source jniLibs directory to reduce the apk size? If so, which targets should I remove? I am targeting relatively new devices so as long as it runs on newer devices I am fine with it.

paradite
  • 6,238
  • 3
  • 40
  • 58

1 Answers1

2

The general ranking of architectures by popularity would be ARM, x86, and then MIPS. The problem is that 64-bit is future facing so depending on how willing you are to give them up means that your 32-bit code on a 64-bit architecture might take some performance hit.

Alternatively use Multiple APK support in Google Play to deliver the correct architecture's APK to your user to reduce size/download time at the cost of the associated complexity.

Updated

Support for 32-bit code on 64-bit architectures is mandated by the Android Compatibility Definition Document Section 3.3.1

MUST support the equivalent 32-bit ABI if any 64-bit ABI is supported

Google doesn't want new 64-bit devices to break on 32-bit binaries as there is quite a bit of 32-bit code in the ecosystem (i.e. games).

Morrison Chang
  • 11,691
  • 3
  • 41
  • 77
  • So if I remove `x86_64`, then the app would still work on `x86_64` if I have `x86`? I wouldn't mind some performance drop since it is not the main feature. – paradite Nov 22 '15 at 18:50
  • for arm which has `arm64-v8a, armeabi, armeabi-v7a`, it is safe to remove `arm64-v8a`? If so, which one would be considered the 32-bit equivalent? – paradite Nov 22 '15 at 19:09
  • You can remove `arm64-v8a`. Actually both `armeabi` and `armeabi-v7a` are 32-bit. The first one is for older ARMv6 while the latter is for ARMv7. Most newer phones are ARMv7. While the Play store should exclude `armeabi` if you don't include it, I would put in a check http://stackoverflow.com/questions/11989629/api-call-to-get-processor-architecture and tell the user that it won't run on that device. – Morrison Chang Nov 22 '15 at 19:19