Using System.getProperty(“os.arch”) to check if it is armeabi cpu

寵の児 提交于 2019-12-07 05:40:25

问题


I'm having the following issue with RenderScript on some old 4.2.2- devices (galaxy s3 mini, galaxy ace 3, galaxy fresh, etc.) - Android - Renderscript Support Library - Error loading RS jni library.

I want to implement the suggested solution but what exactly will be the value returned by

System.getProperty("os.arch");

for armeabi devices (not armeabi-v7 devices).

Thanks.


回答1:


The method System.getProperty is a generic method of Java, here you can find the documentation.

On Linux it returns the same value obtained from the command uname -m. The possible values are for example armv5t, armv5te, armv5tej, armv5tejl, armv6, armv7, armv7l, i686 and many more. There isn't an exact value for the armeabi devices because it slightly differs from cpu to cpu.

There is a better alternative to System.getProperty and it is the field Build.CPU_ABI (or Build.SUPPORTED_ABIS in newer devices):

String abi = null;

if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
    abi = Build.CPU_ABI;
} else {
    abi = Build.SUPPORTED_ABIS[0];
}

The possible values are armeabi, armeabi-v7a, arm64-v8a, x86, x86_64, mips, mips64.

As you can see the number of possible results is much lower than System.getProperty, and you can check directly for armeabi.



来源:https://stackoverflow.com/questions/33694596/using-system-getpropertyos-arch-to-check-if-it-is-armeabi-cpu

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