How to target multiple architectures using NDK?

后端 未结 2 672

Background

I\'ve recently started to develop some code using the NDK, and I\'ve thought of a possible portability problem that could occur while developing using N

相关标签:
2条回答
  • 2020-12-29 05:30

    For the latest version (now r9) you have to specify in "jni/Application.mk"

    APP_ABI := all
    

    or

    APP_ABI := armeabi armeabi-v7a x86 mips
    

    without ./ndk_build will only build 'armeabi'

    0 讨论(0)
  • 2020-12-29 05:36

    If you don't set APP_ABI at all, or use

    APP_ABI := all
    

    in your Application.mk, then ndk-build will build for all architectures supported by your version of NDK. The latest one, to date r8d, will in addition to armeabi armeabi-v7a x86 build also for mips. When another architecture will be released, you will hopefully automatically get the APK built to support it.

    When you application is installed on an Android device, the system will automatically choose the matching ABI version and install the correct shared libraries from the APK.

    One drawback of this approach is that if the native libraries are big, your "monolithic" APK file may become huge. You can use the multi-APK approach to make user downloads smaller. The official site recommends: You should generally use multiple APKs to support different device configurations only when your APK is too large (greater than 50MB). You should carefully follow the version code guildlines if you choose this route.

    Unfortunately, there are no trustworthy prophecies regarding NDK support on Google TV, but there seem to be no technical justification for its current unavailability. If and when it arrives, your ndk-build will take care of it automatically.

    UPDATE Here is a simple process to maintain split APK. And by the way, the new Android TV does support NDK.

    0 讨论(0)
提交回复
热议问题