API call to get processor architecture

后端 未结 8 2027
野的像风
野的像风 2020-12-05 01:59

As part of my app I\'m using the NDK and was wondering if it\'s worth bundling x86 and mips binaries alongside the standard ARM binaries.

I figured the best way woul

相关标签:
8条回答
  • 2020-12-05 02:40

    Try this command:

    adb shell getprop ro.product.cpu.abi
    

    It tells whether cpu is ARM or Intel , 64 or 86_64

    0 讨论(0)
  • 2020-12-05 02:46

    You can use adb command

    adb shell getprop ro.product.cpu.abi adb shell getprop ro.product.cpu.abi2

    and refer the [site]: How to know a process of an app is 32-bit or 64-bit programmatically in Android lollipop?

    If you're looking for the Lollipop API

    import android.os.Build;
    
    Log.i(TAG, "CPU_ABI : " + Build.CPU_ABI);
    Log.i(TAG, "CPU_ABI2 : " + Build.CPU_ABI2);
    Log.i(TAG, "OS.ARCH : " + System.getProperty("os.arch"));
    
    Log.i(TAG, "SUPPORTED_ABIS : " + Arrays.toString(Build.SUPPORTED_ABIS));
    Log.i(TAG, "SUPPORTED_32_BIT_ABIS : " + Arrays.toString(Build.SUPPORTED_32_BIT_ABIS));
    Log.i(TAG, "SUPPORTED_64_BIT_ABIS : " + Arrays.toString(Build.SUPPORTED_64_BIT_ABIS));
    
    0 讨论(0)
  • 2020-12-05 02:48

    You can use the Build class:

    import android.os.Build;

    and then read:

    Build.CPU_ABI

    0 讨论(0)
  • 2020-12-05 02:50

    The values you are looking for are

    ro.product.cpu.abi

    and

    ro.product.cpu.abi2

    These can be got using internal api SystemProperties.get So you will have to use Reflection on SystemProperties.

    You could use the function getSystemProperty if you are not too keen on reflection. Check it here

    0 讨论(0)
  • 2020-12-05 02:52

    My Code looks like this

    private String cpuinfo()
    {
    String arch = System.getProperty("os.arch");    
    String arc = arch.substring(0, 3).toUpperCase();
    String rarc="";
    if (arc.equals("ARM")) {
        rarc= "This is ARM";
        }else if (arc.equals("MIP")){
            rarc= "This is MIPS";
        }else if (arc.equals("X86")){
            rarc= "This is X86";
        }
        return rarc;
    }
    
    0 讨论(0)
  • 2020-12-05 03:02

    You can also use android SDK, take a look on the Build class:

        /** The name of the instruction set (CPU type + ABI convention) of native code. */
        public static final String CPU_ABI = getString("ro.product.cpu.abi");
    
        /** The name of the second instruction set (CPU type + ABI convention) of native code. */
        public static final String CPU_ABI2 = getString("ro.product.cpu.abi2");
    
    0 讨论(0)
提交回复
热议问题