How to force Android application to use either 32bit or 64 bit libraries

别说谁变了你拦得住时间么 提交于 2019-12-31 10:01:32

问题


On a Android device with 64bit ARM, would have two variants of many libraries, 32bit and 64 bit, and their performance could be different. I want to know if there is a way to force the application to use either 32bit or 64bit libraries.


回答1:


ABI can be specified when the apk is installed.

adb install --abi <path to apk>

In case ARM device,

To run in 32 bit mode install using,

adb install --abi armeabi-v7a <path to apk>

To run in 64 bit mode install using,

adb install --abi arm64-v8a <path to apk>




回答2:


  1. If your apk is written in pure java (without jni), on 64-bit-primiary/32-bit-secondary Android OS, your app will always run in 64 bit mode by default, but if you want your app to run in 32 bit mode, you can create a dummy *.so file and put it under <your apk name>/libs/armeabi/ to force AndroidRuntime to create a 32 bit VM for your app

  2. If some function of your apk is written in jni (there's any *.so file in <your apk name>/libs/ folder), you can use following command to make it run in 64 or 32 bit VM:

    • To run in 32 bit mode, because only 32 bit native libs will be installed

    adb shell install --abi armeabi-v7a <path to your apk>

    • To run in 64 bit mode, because only 64 bit native libs will be installed

    adb shell install --abi arm64-v8a <path to your apk>




回答3:


https://source.android.com/source/64-bit-builds.html

Try this in you Android.mk

LOCAL_MULTILIB := 32 // or 64


来源:https://stackoverflow.com/questions/31861807/how-to-force-android-application-to-use-either-32bit-or-64-bit-libraries

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!