Android Studio-- Cause: error=86, Bad CPU type in executable
Asked Answered
S

10

45

Android Studio throws an error while building the project.

the error is :

Cause: error=86, Bad CPU type in executable.

enter image description here

The detail error: enter image description here

Bad CPU type in executable --> Can not run command xxx/aapt

Supposititious answered 12/6, 2019 at 2:29 Comment(3)
31251187 maybe similar with this questionSolana
Can refer to this - similar issue: https://mcmap.net/q/373925/-renderscript-broken-on-macos-catalina-10-15Alleviate
For the M1 Chip sets: softwareupdate --install-rosetta Looks like ADB has not been built for the ARM chip set yet. See issuetracker.google.com/issues/160004878Cheke
S
27

Finally I solved this by a little change.

goto the error module and changed the buildToolsVersion to anther(bigger version) in build.gradle file.

rebuild again, the error disappeared.

Supposititious answered 14/6, 2019 at 7:29 Comment(1)
Modifying buildToolsVersion resolved this issue. Looks like this is introduced in latest android studio version.Woven
E
76

ADB doesn't support ARM, it needs Rosetta to run. I fixed this issue by installing Rosetta. Open Terminal and run the following command:

softwareupdate --install-rosetta
Eade answered 17/10, 2021 at 18:17 Comment(0)
S
27

Finally I solved this by a little change.

goto the error module and changed the buildToolsVersion to anther(bigger version) in build.gradle file.

rebuild again, the error disappeared.

Supposititious answered 14/6, 2019 at 7:29 Comment(1)
Modifying buildToolsVersion resolved this issue. Looks like this is introduced in latest android studio version.Woven
K
20

I fixed this error by installing rosetta. Try running this command in your terminal

softwareupdate --install-rosetta

Keikokeil answered 1/10, 2021 at 7:36 Comment(0)
V
9

If you using mac m1
First, open the terminal after copy paste this command

softwareupdate --install-rosetta

and after that, press "a"

enter image description here

Vociferate answered 14/11, 2021 at 12:38 Comment(1)
This has already been mentioned in some of the other answers.Superior
M
7

Upgrading buildToolsVersion is not work for me, but after upgraded gradle version, the error disappeared.

buildscript {
repositories {
    jcenter()
    google() <--don't forget to add this
}

dependencies {
    classpath 'com.android.tools.build:gradle:3.5.3' <--upgrade here
}
Manara answered 10/12, 2019 at 3:13 Comment(0)
J
4

I'm not 100% sure but seems like updating AGP to 7.1.0 solves the issue.

Johan answered 26/1, 2022 at 21:19 Comment(0)
D
4

Following working fine for Mac M1 users (If ARM version of android studio is installed --> android-studio-2021.x.x.xx-mac_arm.dmg)):

Open terminal and install rosetta:

softwareupdate --install-rosetta

press a and the press enter(return) key.

Now rebuild or sync your project. It will work smooth.

Drye answered 4/4, 2022 at 15:5 Comment(0)
P
2

Android Studio has built-in installer for M1 ARM64 architecture compatible Java:

Android Studio -> Preferences -> Gradle -> Gradle JDK -> Download JDK...

installer

You feel free to select anything that have aarch64 tag. Azul for example

After that, run ./gradlew clean to see, that your project is used fresh ARM supported JDK.

But, for some cases (like adb) you need to install rosetta. Other things, like building project going directly through ARM without binary translator.

Pyrrhonism answered 3/12, 2021 at 6:21 Comment(0)
C
1

My issue was other way around. My Mac was on Intel chip but looks like I had downloaded and pointed to JDK 17 that was meant for M1 Chip. I had to go to Android Studio -> Preferences -> Gradle -> Gradle JDK and selected an embedded JDK.

Caballero answered 17/5, 2023 at 13:57 Comment(0)
D
1

It seems like the AGP need to upgrade. After upgrading AGP to 7.0.4 , and then it resolve the issue

Delvalle answered 4/7, 2023 at 8:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.