I want to compile an open source android project (Netguard) using gradel (gradlew clean build
) But I encountered this Error:
A problem occurred
To fix it like i did
Android Studio File> project structure and go to project
change Gradle version to 4.6 & Android plugin version to 3.2.1
check screenshot
then clean project if you got this Error "Could not find aapt2-proto.jar"
go to build.gradle (project)
Try moving the google() method (.gradle file) to the top of its execution block the order of repositories it searches in that causes the issue.
for example, change this:
repositories {
maven { url 'https://maven.fabric.io/public' }
google() <=== from here
mavenCentral()
}
To this:
repositories {
google() <=== to here
maven { url 'https://maven.fabric.io/public' }
mavenCentral()
}
Make those changes in both "buildscript" and "allprojects "
check screenshot
If you didn't find google() add it
Android NDK 18.0* seems has an issue not creating all the files in folders after extraction. Due to it, your app compilation will fail which uses ndk builds.
Better is to use NDK 17.1* (https://developer.android.com/ndk/downloads/) etc version and you can extract or use the android studio extraction to ndk-bundle by default will work good.
I've had a similar problem, but I wanted to use NDK version r9d due to project requirements.
In local.properties
the path was set to ndk.dir=C\:\\Android\\ndk\\android-ndk-r9d
but that lead to the problem:
No toolchains found in the NDK toolchains folder for ABI with prefix: [toolchain-name]
The solution was to:
sdk\ndk-bundle\toolchains
to \ndk\android-ndk-r9d\toolchains
It looks to me that the copied toolchains are not used, but for some reason it is needed to for them be there.
Step-by-step:
1) Open the page with old NDK versions:
https://developer.android.com/ndk/downloads/older_releases
2) Agree the Terms:
3) Download the older version of NDK
(for example 16b):
4) Open your toolchains
directory.
5) Transfer files that you need from toolchains
folder of downloaded zip-file to your toolchains
folder:
6) Rebuild the Project:
UPD 30 Sep 2018:
I used Android NDK Revision r16b for fix this error in my own case. So I present the example with this version.
But it's better to use the Android NDK, Revision r17c (June 2018). It is the last one, supporting mips (reasonable reccomendation from Weekend's comment).
Navigate to C:\Users\lalit\AppData\Local\Android\Sdk\ndk-bundle\toolchains
.
Now, find the folder name aarch64-linux-android-4.9
and rename it to mips64el-linux-android
.
Re-run the android app.
The issue comes mostly when you are cloning a previous project specially from github. What you can do is
classpath 'com.android.tools.build:gradle:3.2.1'
in your project level gradle.
Then Change all the instances of compile with implementation except compileSdkVersion keep it as it is in your app level gradle.
Instead of sync now click on make project(Ctrl+F9)
Add google maven repositories if needed.
Upgrade the gradle wrapper if needed.
(Android Studio IDE will ask / guide you with the same for steps 4 and 5)
it fixes!! Enjoy Coding