Android app build failing with gradle - android

I am the error when trying to build an existing project in android studio 2.2.3
FIRST ERROR
Error:(1, 1) A problem occurred evaluating project ':app'.
Failed to apply plugin [id 'com.android.application']
Could not create plugin of type 'AppPlugin'.
The android gradle plugin version 2.3.0-beta1 is too old, please update to the latest version.
To override this check from the command line please set the ANDROID_DAILY_OVERRIDE environment variable to "38489eef475e39c9974f03c995d6529764875fa8"
Next step - Update latest build version
dependencies {
classpath 'com.android.tools.build:gradle:2.5.0-alpha-preview-01'
SECOND error
Error:Unable to find method 'org.gradle.api.artifacts.dsl.DependencyHandler.registerTransform(Ljava/lang/Class;Lorg/gradle/api/Action;)V'.
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.

If you are on Windows Environment, open System properties(right click My Computer), set(add if not there) environment variable ANDROID_DAILY_OVERRIDE, and set the value to 38489eef475e39c9974f03c995d6529764875fa8 or whatever coming on message log.
Restart your Android studio, project should build without any issues.
I was also facing this Daily Override issue after upgrading Repository it is gone now so also update your Android Studio.
Hope this helps!

Based on your original question, you are unlikely to want to use 2.5 at this point. We only released 2.5 alpha preview primarily for advanced early adopters to try at this point.
The reason you were getting the error is because preview versions of the Android Gradle plugin are time-bombed. You just need to update to a newer version. Simply change your line to:
classpath 'com.android.tools.build:gradle:2.3.0-rc1'
Once we publish the stable version, you can then change to:
classpath 'com.android.tools.build:gradle:2.3.0'
The stable version won't be time-bombed. Hope it helps.
If you haven't updated the Gradle version, you will need to update it to 3.3.

You might look at http://tools.android.com/tech-docs/new-build-system/2-5-alpha-gradle-plugin/trying-gradle-plugin-2-5 when you are using com.android.tools.build:gradle:2.5.0-alpha-preview-01

Related

Gradle build process is failing

My project was successfully building and all of a sudden I got the below error in Android studio.
Unable to find method 'org.gradle.api.publish.maven.internal.publication.MavenPublicationInternal.getPublishableFiles()Lorg/gradle/api/file/FileCollection;'.
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 tried clearing the local dependency cache and rebuilding the project. But still the error persists.
I am using android studio v4.0 with build tools v29.0.2.
Is it because gradle can't download the dependency from maven repo?
Is it because there is an error in configuring maven in my 'respositories' list?
How can I get more information on this error?
Try to update the com.jfrog.artifactory version.
My resolution for this was to update the artifactory version like #disha4mourya suggested - add this block to your project's build.gradle, directly after your buildscript block:
plugins {
id "com.jfrog.artifactory" version "4.18.3"
}

Android Studio 3.4/Gradle v5 Update Error

I updated my version of Android Studio to 3.4, it then asked me to upgrade Gradle to v5.1.1 from v4.10.1.
However the gradle project sync keeps failing now:
ERROR: Unable to find method
'org.gradle.api.tasks.SourceSetOutput.getClassesDir()Ljava/io/File;'.
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've tried all of those options but I'm still getting the same error. I found the below information about upgrading from v4 to v5:
The classesDir property has been removed from both the JDepend task
and SourceSetOutput. Use the JDepend.classesDirs and
SourceSetOutput.classesDirs properties instead.
https://docs.gradle.org/current/userguide/upgrading_version_4.html
The only useful information it provides it to use the properties mentioned instead. But I don't know what I need to be replacing, I can't see SourceSetOutput being used anywhere in my code. I don't suppose anyone else has come across this or knows how to fix this issue?
I have also tried upgrading to the latest Gradle version which is 5.4.1 but that doesn't seem to make a difference.
Just update Android Studio to 3.4 stable version. This is working for me :)

Gradle project sync failed after update - Unable to find method 'com.google.common.collect.ImmutableSet.toImmutableSet()Ljava/util/stream/Collector;'

I recently opened up an old project, updated Android Studio to 3.1.3, and am now unable to run the project. This is the message I receive:
Unable to find method 'com.google.common.collect.ImmutableSet.toImmutableSet()Ljava/util/stream/Collector;'.
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.
This message is followed up by this one on the second attempt:
Could not initialize class com.android.build.gradle.internal.ide.ModelBuilder
Gradle Project sync failed
The gradle project sync keeps failing, I've tried all of these solutions below, including invalidating/restarting cache, deleting .gradle file, etc.
Unsuccessful solutions
I'm not an Android wiz, so if anyone can lead me in the right direction it would be greatly appreciated!
I suspect that this has to do with conflicts in Guava depending on the
Gradle version you use and the Guava version your dependencies use.
The function toImmutableList was added in Guava 21 (Guava 20).
I suggest you try downgrading the project's gradle version to 3.3 or so and try again.

Downgrade Gradle from 3.3 to 2.14.1

Long story short: My android phone keeps disconnecting from ADB. I was told to update android studio, did that. I open my project in Intellij and try to run on android and I get an error:
BUILD FAILED
Total time: 48.986 secs
Error: /Users/me/Desktop/comp/Development/comp-ionic/platforms/android/gradlew: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileDebugJavaWithJavac'.
> java.lang.NullPointerException (no error message)
My first thought is that my gradle is the wrong version. For this specific app, I need to use gradle version 2.14.1.
When I type gradle -v I'm getting version 3.3.
Is there a way to delete/downgrade gradle from 3.3 to 2.14.1?
Or is this another problem?
If you're using the gradle wrapper, then there'll be a folder in your project named "gradle" with a subfolder named "wrapper", inside that, there are 2 files:
- gradle-wrapper.jar
- gradle-wrapper.properties
Open "gradle-wrapper.properties" and change the place where it says "3.3" to "2.14.1". Then sync gradle, and it will automatically download 2.14.1.
If you're using the new 2.3 Android Studio, you HAVE to use gradle wrapper 3.3, as its the minimum supported gradle wrapper version. If so, then you'll have to download Android Studio 2.2, or fix whatever issue you have in your project that needs gradle wrapper version 2.14.1.
To get more information about whatever the issue is, try running this:
./gradlew clean assemble -stacktrace
That will clean your project, try and compile it, and if/when it fails, it will show you a stacktrace of the error.
What you should do is to change the gradle build tools version to the one that matches your gradle version. According to here you can set the gradle to 2.14.1 by changing build tools to lower than 1.0.0.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0'// For gradle 2.2.1 - 2.3
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
Notice: if you keep checking the mentioned link you'll see Higher is better for gradle.
For me, Android Studio > File > Invalidate Caches / Restart did the trick.
I got the same problem when upgrading to Android Studio 2.3.1. There is something funky about Gradle 3.3 (It fails by "java.lang.NullPointerException: null value in entry: destinationDir=null at com.google.common.collect.CollectPreconditions.checkEntryNotNull(CollectPreconditions.java:33)").
Good news: seems like the current most recent version (3.5) works.
Go to File|Project Structure|Project, and use these versions:
Gradle version=3.5
Android Plugin version=2.3.1
I update the Android Studio version to 3.3 Canary 4, then update the gradle plugin, and the project stops working.
I do not know how to restore my AS to the previous state, nighter the gradle plugin.
But just with this command, the project now works, for me: gradlew clean assemble -stacktrace, in terminal tab in AS.

Gradle error after studio update

I've recently upgraded from 1.2.2 to 1.3.2 and was introduced with the following error:
Error:Unable to load class 'org.gradle.api.publication.maven.internal.DefaultMavenFactory'.
Possible causes for this unexpected error include:You are using JDK version 'java version "1.7.0_79"'. Some versions of JDK 1.7 (e.g. 1.7.0_10) may cause class loading errors in Gradle.
Please update to a newer version (e.g. 1.7.0_67).
Open JDK Settings
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.
My project is using the SquiDB library if that matters, has anyone encountered similar error and could help me out how to fix it?
I don't know why but following has worked:
Open the Settings panel
Go to Build, Execution, Deployment > Build Tools > Gradle
On right in the form under the Project-level settings heading select Use default gradle wrapper (Recommended)
In my case I had selected Use local gradle distribution for some reason.
if you know the reason behind the issue and solution applied please add another answer with explanation and I will make it accepted.
if your gradle.properties file which is located at the root level of your project contains :
classpath 'com.github.dcendents:android-maven-plugin:1.2',
try to change to:
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
I solved the same problem in this way, and hope you will as well.

Categories

Resources