How do I get rid of this Gradle error? - android

Could not find com.android.tools.build:gradle:4.1.
Searched in the following locations:
https://jcenter.bintray.com/com/android/tools/build/gradle/4.1/gradle-4.1.pom
https://jcenter.bintray.com/com/android/tools/build/gradle/4.1/gradle-4.1.jar
https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle /4.1/gradle-4.1.pom
https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/
4.1/gradle-4.1.jar
https://maven.google.com/com/android/tools/build/gradle/4.1/gradle-4.1.pom
https://maven.google.com/com/android/tools/build/gradle/4.1/gradle-4.1.jar
Required by:
project :
Open File
I downloaded the source code of an app and when I try to run I get all kinds of gradle errors. I have been trying to solve it since two days but so far I have been unable to do so. I updated Android Studio to 3.1 but the error is still there. Nothing works.
Here is what I have tried so far:
I deleted all the gradle version in the 'dist' folder and let
Android Studio download everything again.
I have tried to enable
'offline mode' in the Gradle build settings in Android Studio.
I also enabled 'use local gradle distribution'.
P.S: Creating a new project works fine. I just need to run this specific project.

The Gragle version declared is 4.1, but since you are using Android Studio 3.1, the gradle version should be declared as follow into your application build.gradle:
buildscript {
...
dependencies {
classpath 'com.android.tools.build:gradle:3.1.0'
...
}
}
You can find the link between the gradle plugin version and the actual gradle version here

Related

Android Studio - Could not parse the Android Application Module's Gradle config. Resolve gradle build issues and/or resync

When connecting to Firebase via assistant tool in Android Studio, clicking on connect to Firebase, gives me this error:
Could not parse the Android Application Module's Gradle config. Resolve gradle build issues and/or resync.
I have already tried to remove dependencies and Google services plugin.
Error dialog
Gradle build file screenshot
Gradle build file screenshot
Your build.gradle file should not contain any warnings or errors. and also remove jcenter(). in my case, it worked...

Unsupported method: AndroidArtifact.getBuildConfigFields()

I have just updated to Android Studio 4.0 and trying to build my project. I keep on getting the below error
Unsupported method: AndroidArtifact.getBuildConfigFields().
The version of Gradle you connect to does not support that method.
To resolve the problem you can change/upgrade the target version of Gradle you connect to.
Alternatively, you can ignore this exception and read other information from the model.
I am already using the latest version of Gradle and Gradle Plugin
Gradle version:
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-milestone-1-all.zip
Gradle plugin tools version:
classpath 'com.android.tools.build:gradle:4.1.0-alpha10'
Any solution or fix for this problem would be helpful. Thanks in advance.
Use Android studio 4.1 preview
or
classpath 'com.android.tools.build:gradle:4.0.0'
This is usually due to a mismatch between your Android Studio versions and the Android Gradle plugin.
You can find the version of Android Studio on the project selection window when you first open it (or in "Android Studio > About Android Studio" on Mac, and similar location on other platforms). For example, you might be using Android Studio 4.0.1.
You can find the Android Gradle plugin version for your project in the top-level build.gradle file.
You should find something like the following:
buildscript {
[...]
dependencies {
classpath 'com.android.tools.build:gradle:4.0.1'
[...]
}
[...]
}
You need to make sure that the two version numbers match (in this case they do).

gradle error in unity exported android project

I am going to use the build config property "multiDexEnabled true" to break 64K methods limit following link
https://developer.android.com/studio/build/multidex.html#about
I update to use unity 5.6.1f1 and android studio 2.3.3. I set "build system" option to "Gradle(New)", which is new added from 5.5, then click "Export" to create an android project.
I open the exported project with android studio, then I get the following error
I try the two blue links, but I keep geting this same result.
For my unity project, I only create an empty project and add a button to a unity scene, then export it. I have also tried to build API directly, it works.
It is important for me to export unity project to andoid studio project, because it can help us to use additional compile options
Do any one know what I miss? Or how to export unity project correctly?
Thanks
The gradle error text, if cannot see the image link
Error:org.gradle.api.internal.tasks.DefaultTaskInputs$TaskInputUnionFileCollection cannot be cast to org.gradle.api.internal.file.collections.DefaultConfigurableFileCollection
Possible causes for this unexpected error include:Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)
Re-download dependencies and sync project (requires network)The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem.
Stop Gradle build processes (requires restart)Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project.In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.
I had the same issue with unity 2017.1.0b4 and Android Studio 2.3.3, gradle 3.3.
You should change android plugin for graddle version in Android studio to 2.3.3
You can specify the Android plugin for Gradle version in either the
File > Project Structure > Project menu in Android Studio, or the
top-level build.gradle file. The plugin version applies to all modules
built in that Android Studio project. The following example sets the
Android plugin for Gradle to version 2.3.3 from the build.gradle file:
buildscript {
...
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
}
}
https://developer.android.com/studio/releases/gradle-plugin.html
Check your local gradle version in directory -
C:\Users\yourname\.gradle\wrapper\dists
Modify your project gradle configuration -
project\gradle\wrapper\gradle-wrapper.properties
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
Make sure gradle-3.3-all match to your gradle version.
If you have wasted a lot of time fixing unity Gradle error but nothing worked then you tried unity internal builder but that gave "Parsing Package error"
then try this, it will not help you make your project using unity's Gradle but it will make your project without any error successfully.
Export your project from unity to a folder eg: ProjectName_Gradle.
open android studio, make sure you are connected to the internet .
close current project then select "Open Gradle, eclipse ADT, etc;" option and open ProjectName_Gradle folder.
check the version of buildTools installed in your android-SDK by opening android-SDK settings from the android studio itself.
edit "build.gradle" file under Gradle Scripts section or under your project.
and change "buildToolsVersion" to the latest version installed in your SDK.
then click "syn project with Gradle Files" from file option and let it sync.
it may ask to update Gradle version, then click update
now there should not be any errors.
now try building APK.

Import a project to Android studio faced problems

I want reading an open source project so I select k9mail for start. The recommendation was run and reading this code in Android Studio. I import k9mail project to AS 1.2.1.1 version. I download gradle 2.4 version and added this in environment variable. When I want to run this application, but I receive some errors that I describe below:
1) When I click Run (Alt+Shift+F10), select Android Application, select my module (there is k9mail) and select USB Device, then I see a warning:
No JDK specified for module 'k-9-master'.
2) When I click on Run (Shift+F10), I faced this error in messages tab:
Gradle DSL method not found: 'android()'
Possible causes:
A)The project 'k-9-master' may be using a version of Gradle that does not contain the method.Open Gradle wrapper file
B)The build file may be missing a Gradle plugin. Apply Gradle plugin
When I updated gradle to 2.4, I changed classpath 'com.android.tools.build:gradle:1.2.3' to 'classpath 'com.android.tools.build:gradle:2.4'' from build.gradle of k9mail, but my problems were not solved.
I googled but I can't find solutions for my problems.
No jdk specified for the module.
For that you have to specify the jdk path through Project Structure.
You may also verify by looking at local.properties
For gradle related issues you just kindly update your gradle build and SDKs to latest versions.
This will minimize your gradle issues.

Android Studio installation doesn't work with gradle

I am absolute beginner with Android Studio (especially Gradle) and having big trouble getting Android Studio to work. I downloaded and installed the most recent version of Android Studio (0.8.0). I have set the JDK_HOME variable. However, after I create a new project, I always receive the following message:
Error:Unknown host 'jcenter.bintray.com'.
Enable Gradle 'offline mode' and sync project.
Learn about configuring HTTP proxies in Gradle
If I try to compile the project, I get the following message dialog:
After reading a post, I manually downloaded the Gradle binaries (latest, 2.0), extracted it onto the local drive, went to Settings and set the Gradle path to the respective directory using the following:
I also tweaked the build.gradle file under the project to point to the latest Gradle 2.0 version. However, now I get the following error message:
Error:A problem occurred configuring root project 'HelloAndroidStudio'.
Could not resolve all dependencies for configuration ':classpath'.
Could not resolve com.android.tools.build:gradle:2.0.+.
Required by:
:HelloAndroidStudio:unspecified
Failed to list versions for com.android.tools.build:gradle.
Unable to load Maven meta-data from http://jcenter.bintray.com/com/android/tools/build/gradle/maven-metadata.xml.
Could not GET 'http://jcenter.bintray.com/com/android/tools/build/gradle/maven-metadata.xml'.
jcenter.bintray.com
Please can someone help. Being my first time with Gradle, I have been trying for so many days without any clue to the problem. Thanks.
Change the Gradle version to lower ones and restart the Android Studio, you may get it.
Add this in build.gradle
classpath 'com.android.tools.build:gradle:1.1.0'
Setting the http_proxy under appearance & behaviour -> system settings -> http proxy has solved the problem
Change to the latest classpath in the dependencies.
For AS 1.5.1 I will do like this :
buildscript {
repositories {
jcenter()
}
dependencies {
**classpath 'com.android.tools.build:gradle:1.5.0'**
}
}

Categories

Resources