I want to compile an open source android project (Netguard) using gradel (gradlew clean build
) But I encountered this Error:
A problem occurred
In my limited experience with this question,I try to solve the problem use follow method:
1.Stay android build tools version the same with gradle version. For example:if you use the build tools version is 3.3.0,your gradle version must be 4.10.1.You can reference by the link https://developer.android.com/studio/releases/gradle-plugin and chagne your build tools & gradle version in your AS(File->Project Structure->Project)
2.If method1 don't work,you can custom your ndk toolchains version to solve the problem :like download ndk18 or ndk16 , setting the ndk path is your AS(File->Project Structure->SDK Location->Android NDK Location)
Two years has passed, now if you come across here, you may possibly encounterd error message like this:
No toolchains found in the NDK toolchains folder for ABI with prefix mips64el-linux-android
or
No toolchains found in the NDK toolchains folder for ABI with prefix mipsel-linux-android
Latest NDK removed support for mips
abi, and earler version of android gradle plugin still check for the existance of mips toolchain. see here for more info.
Solution: Upgrade android gradle plugin to 3.1 or newer.
e.g. Add following in the project level gradle [28-Sept-2018]
classpath "com.android.tools.build:gradle:3.2.0"
Workaround: Create mipsel-linux-android
folder structure to fool the tool. The easiest way would be to symbolic link to aarch64-linux-android-4.9
.
# on Mac
cd ~/Library/Android/sdk/ndk-bundle/toolchains
ln -s aarch64-linux-android-4.9 mips64el-linux-android
ln -s arm-linux-androideabi-4.9 mipsel-linux-android
Check this thread of three options for solving this kind of issue
I solved this question by unInstalled ndk, becasuse I dont't need it
Here is the fix.
When compiling a project in android studio, I occasionally encounter:
Error: No toolchains found in the NDK toolchains folder for ABI with prefix: arm-linux-androideabi/llvm
This may be caused by updating related components. The solution is to Android studio ( Tools -> Android -> SDK Manager ) . Select the ndk item and delete it. If the program needs it, you can re-install it. This will ensure that the folder location is correct and there will be no such problem.
Find your own local android-SDK, if you download the relevant SDK of ndk, there will be a folder called "ndk-bundle"
There is a folder called "toolchains" inside.
We noticed that there are no mips64el related files inside.
The solution is as follows:
Click here to download the NDK package separately through the browser. After unzipping, open the "toolchains" folder, compare it with the android-sdk->ndk-bundle->toolchains folder, find the missing folder, copy the past three. Recompile, the problem is solved.
First, try updating the ndk version https://developer.android.com/ndk/downloads/
If that's not working then you can try the following:
Create a folder
Go to the Sdk\ndk-bundle\toolchains folder (in my case its C:\Users\USER\AppData\Local\Android\Sdk\ndk-bundle\toolchains; you can find yours under File->project structure->SDK location in you android studio) and create a folder with the name that's shown as missing in the error for eg: if the error is
Gradle sync failed: No toolchains found in the NDK toolchains folder for ABI with prefix: mipsel-linux-android
Then create a folder with name mipsel-linux-android
Include content Go to the Sdk\ndk-bundle\toolchains folder again and open any folder that's already in it. For example:Sdk\ndk-bundle\toolchains\aarch64-linux-android-4.9 (in mycase C:\Users\USER\AppData\Local\Android\Sdk\ndk-bundle\toolchains\aarch64-linux-android-4.9) copy the prebuilt folder in it to the folder we created in the last step
Run the project again and it will work
Hope it helps!!