Issue
We're trying to reduce the size of an APK we're building by using packagingOptions
to exclude native libraries for some architectures that aren't popular for the app - we're happy for parts of the app to not work on those:
packagingOptions {
exclude 'lib/x86/lib.so'
exclude 'lib/x86_64/lib.so'
}
Of course, we don't want to cause the app to not be able to install (because of an INSTALL_FAILED_NO_MATCHING_ABIS
from missing architectures) so we include we include an AAR with zero byte stubs. The contents of the AAR looks like this:
$ jar tf stubs.aar
jni/
jni/armeabi-v7a/
jni/armeabi-v7a/stub.so
jni/x86/
jni/x86/stub.so
jni/arm64-v8a/
jni/arm64-v8a/stub.so
jni/armeabi/
jni/armeabi/stub.so
jni/x86_64/
jni/x86_64/stub.so
However, we found that while this solution mostly worked as expected we still couldn't install the app on the standard Android SDK emulator with an x86 image. Digging deeper we found that we could install the app on the emulator using x86 images for API 26+ but that installing on API 21-25 failed with a INSTALL_FAILED_NO_MATCHING_ABIS
.
Is there any reason zero byte stubs would not be a solution to this problem on API 21-25?
EDIT: With some further testing it looks like the install does work for API 16-19 and that only 21-25 are the problem.
Solution
After some playing around we found the answer was quite simple (although a little weird): the API 21-25 emulator images would not recognize an architecture unless it contained files that looked like valid libraries and in this case that meant having a "lib" prefix. Changing the zero byte stub's filename from stub.so
to libstub.so
fixed the problem.
I believe this is because of the conventions around sonames but don't fully understand why some emulator versions were stricter than others.
Please comment/edit if you can provide more detail!
Answered By - seadowg
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.