Home » Android » How to detect android device is 64 bit or 32 bit processor?

How to detect android device is 64 bit or 32 bit processor?

Posted by: admin June 15, 2020 Leave a comment

Questions:

I’m trying to find a best solution for this question. The reason is the lib in our application can not run with the 64 bit processor so I need to turn it off in this case.
I found that in Android version 21 (lolipop)and higher we can easily detect that the device is 32 bit or 64 bit processor by using Build.SUPPORTED_64_BIT_ABIS and if It returns the String array with 0 elements then… a hah! The device is 32 bit processor.
How about lower android version? Build.SUPPORTED_64_BIT_ABIS just only support from android Lolipop version and higher.
Thanks & Best Regards,
Wish you guys all the best!

How to&Answers:

Simple answer: There’s no need to check for this on Android versions below Lollipop. That’s due the fact that Lollipop introducted platform support for 64-Bit architectures, Android-Versions below Lollipop won’t run with a 64-Bit processor.

Android 5.0 introduces platform support for 64-bit architectures—used
by the Nexus 9’s NVIDIA Tegra K1. Optimizations provide larger address
space and improved performance for certain compute workloads. Apps
written in the Java language run as 64-bit apps automatically—no
modifications are needed. If your app uses native code, we’ve extended
the NDK to support new ABIs for ARM v8, and x86-64, and MIPS-64.
(Source)

Answer:

 try {
            boolean  isArm64 = false;

            BufferedReader localBufferedReader = new BufferedReader(new FileReader("/proc/cpuinfo"));
            if (localBufferedReader.readLine().contains("aarch64")) {
                isArm64 = true;
            }
            localBufferedReader.close();
        } catch (IOException e) {
        }

Or

final boolean is64bit = Build.SUPPORTED_64_BIT_ABIS.length > 0;

Answer:

Firdt connect the device ato system,
on windows type in the command prompt this command

adb shell cat  /proc/cpuinfo | findstr arc

on linux or mac base system open terminal and type this command

  adb shell cat  /proc/cpuinfo | grep arc

if first line of out contain 32 that mean system type is 32bit

first line of out if contain 64 that mean system type is 64bit

Answer:

32Bit if below 5.0, because android support 64Bit Until 5.0.
Judge whether Build.SUPPORTED_ABIS support 64 if above 5.0.

String bits;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
    bits = TextUtils.join(", ", Build.SUPPORTED_ABIS).contains("64") ? "64-Bit" : "32-Bit";
} else {
    bits = "32-Bit";
}

You can view a device is 64bit or 32bit by using Dev Tools.

Answer:

If you’re using ADB

adb shell cat /proc/cpuinfo | grep rch

Most outputs:

Architecture 7 -> 32bit

Architecture 8 -> 64bit

  • this is an extension answer from @Naval Kishor Jha

  • tested in 6 models here

  • no root needed

Answer:

I found the API, distinguish by app process.

Process.is64Bit()

Of course, it can be arm 64 or x86-64.

But if you only package arm share library, the x86 device can’t install you app.

So the method is work.

If you package x86 share library, then above answer SUPPORTED_ABIS is work.