Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Broken android setup #53

Open
alecnotthompson opened this issue Dec 1, 2021 · 4 comments
Open

Broken android setup #53

alecnotthompson opened this issue Dec 1, 2021 · 4 comments
Labels
target: Android type: bug Dang, that shouldn't have happened

Comments

@alecnotthompson
Copy link

alecnotthompson commented Dec 1, 2021

I seem to have had a bad android studio setup on my computer for years from only occasionally having react native gigs and can't figure out how to fix it.

After some toiling I think I have a working installation but can't run a cargo mobile generated project. It works just fine on desktop and iOS simulator (without legacy build system even!) and am getting the following error:

error: Failed to locate required build tool
    Missing tool `ar`; tried at
    "/Users/me/Library/Android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/bin/x86_64-linux-android-ar".

The file is indeed not in the folder it is looking in but I do see some -as files.

Could it be that I have upgraded beyond supported android studio? 😭 I don't know much about the build system or what I'm looking for but I did see this page saying certain things related to standalone toolchains are obsolete when googling things related to the error above.

Any help would be appreciated. I'm excited to finally be digging into a project with this tool!

@zeerooth
Copy link
Contributor

zeerooth commented Dec 2, 2021

Hello!

It seems like the NDK release 23 removed the AR tool that is required for cargo-mobile to work and I see others struggling with a similar issue.

For now, try reverting your NDK version through Android Studio to some earlier version. I've tested with 22.1.7171670 and it appears to be working.

Screenshot from 2021-12-02 21-51-21

Of course eventually, we should probably add support for NDK>=23 but for now this should be a functional workaround.

@lexi-the-cute
Copy link

Hai! The NDK now uses llvm-ar in the same folder

@ethankuhrts
Copy link

Hai! The NDK now uses llvm-ar in the same folder

How can i change cargo mobile to target this instead?

@Alexdelia
Copy link

Alexdelia commented Jul 29, 2023

Hai! The NDK now uses llvm-ar in the same folder

How can i change cargo mobile to target this instead?

a workaround is to create a symlink to all needed file:

export YOUR_ARCH_TYPE=linux-x86_64

# aarch64-linux-android-ar
ln -s $NDK_HOME/toolchains/llvm/prebuilt/$YOUR_ARCH_TYPE/bin/llvm-ar $NDK_HOME/toolchains/llvm/prebuilt/$YOUR_ARCH_TYPE/bin/aarch64-linux-android-ar

# arm-linux-androideabi-ar
ln -s $NDK_HOME/toolchains/llvm/prebuilt/$YOUR_ARCH_TYPE/bin/llvm-ar $NDK_HOME/toolchains/llvm/prebuilt/$YOUR_ARCH_TYPE/bin/arm-linux-androideabi-ar

# i686-linux-android-ar
ln -s $NDK_HOME/toolchains/llvm/prebuilt/$YOUR_ARCH_TYPE/bin/llvm-ar $NDK_HOME/toolchains/llvm/prebuilt/$YOUR_ARCH_TYPE/bin/i686-linux-android-ar

# x86_64-linux-android-ar
ln -s $NDK_HOME/toolchains/llvm/prebuilt/$YOUR_ARCH_TYPE/bin/llvm-ar $NDK_HOME/toolchains/llvm/prebuilt/$YOUR_ARCH_TYPE/bin/x86_64-linux-android-ar

(the folder YOUR_ARCH_TYPE is most probably the only folder in $NDK_HOME/toolchains/llvm/prebuilt/, you just need to look up its name)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
target: Android type: bug Dang, that shouldn't have happened
Projects
None yet
Development

No branches or pull requests

5 participants