Gradle error after studio update - android

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.

Related

Android Studio Error - Unable to load class 'com.google.gson.JsonParseException'

I am getting below error in Android Studio.
I tried these things but it didn't work for me.
Deleted the .gradle folder and resync the project
Manually downloaded the gradle distribution & in settings changed gradle to use from specified location.
Unable to load class 'com.google.gson.JsonParseException'. 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.
Make sure your using suitable version of Gson in gradle file implementation 'com.google.code.gson:gson:<specific version>'
I highly recommend importing the library from your build.gradle instead of downloading it.
It might be a possibility that your Android Studio's gradle caches are corrupt. Fix for that is to got your .gradle folder in you Computer's home directory and navigate to caches folder and delete every thing inside it.

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.

Android app build failing with gradle

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

Categories

Resources