Android gradle plugin error - android

I tried importing a project but got this error. I tried the auto-update to upgrade my gradle plugin but it didn't work. Android gradle plugin error img
Do I need to make changes in build.gradle project file?
Is there any specific way to update my gradle plugin?

In ur build.gradle use this line
classpath 'com.android.tools.build:gradle:1.2.0'
and try to rebuild the project. If the gradle is present the build is success, otherwise it will ask to update the gradle plugin and click on it.So, It will automatically updates and completes build.

Related

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.

Android studio gradle upgrade

Anyone has an idea on how to upgrade gradle from within android studio. The pop-up appears telling me to upgrade gradle but version never updates.
I've tried downloading it and unzipping it in the .gralde folder and changing the path, a gradle error persists and resolving it only re-creates the old gradle file and overwrites the new one.
Set gradle and android plugin version under the Projects tab in Project structure (File -> Project Structure). Clicking Ok will sync gradle files.
Alternatively to update gradle through code this may be helpful.
Update Gradle version
find gradle folder inside your project
Open gradle-wrapper.properties
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
Update Android Gradle plugin
Open build.gradle file of your project
Inside buildscript tag update
classpath 'com.android.tools.build:gradle:2.3.3'
After making these changes refresh gradle dependency.

Gradle sync failed: Access is denied

I have installed Android studio and i have created the new project but it is giving me the error:
Gradle 'MyApplication2' project refresh failed
Gradle sync failed: Access is denied
I have also run android studio as an administrator but it did not work. Please help me with this. How can I build the gradle and run the project.
I have had a similar issue recently when the gradle plugin release was updated to 5.1.1. which caused an error message "apollo\generatedIR\debug (Access is denied)".
In order to fix this I had to revert back to the previous gradle version which was 3.3.2 and I had to make sure that the zip file that is downloaded when the project syncs matched the 3.3.2 version.
Here is where to check the versions of the gradle builds: https://developer.android.com/studio/releases/gradle-plugin
The changes I made where:
In the gradle (project) file change the classpath plugin to the previous version:
classpath 'com.android.tools.build:gradle:3.3.2'
Then in the gradle-wrapper.properties file change the distributionUrl to match the required gradle version.
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
Then resync your project. If it doesn't work double check your gradle files by going to the C:Users//.gradle/wrapper/dists folder and it should match the version on the web page above.
if there is permission related issue. Then you can change the gradle path from C to D drive. it will fix the issue
Go to your project folder right click ->Properties->under Security tab on it check permission and allow all permissions.

Android Studio 2.2 Gradle update fails

New Android Studio ask me about Gradle plugin update
But it fails, when I press Update button.
Failed to update the version of Android Gradle Plugin
How to fix this?
Looks like it's an inner bug of Android Studio
I just change manually
compile 'com.android.tools.build:gradle:2.1.3'
in root build.gradle to
compile 'com.android.tools.build:gradle:2.2.0'
And all started working.
Download gradle this link manually and copy gradle folder
https://services.gradle.org/distributions/gradle-2.14.1-all.zip
Last version :
https://services.gradle.org/distributions/gradle-3.1-all.zip

How to update Gradle Plugin version?

I am trying to run a project and it shows me:
Error running app: This version of Android Studio is incompatible with
the Gradle Plugin used. Try disabling Instant Run (or updating either
the IDE or the Gradle plugin to the latest version)
What should I do?
How can I update gradle?
The gradle plugin is declared inside the build.gradle file in your modules or in your root folder (top-level file).
Use:
classpath 'com.android.tools.build:gradle:2.0.0'
Also this requires gradle 2.10 (don't confuse the gradle plugin with gradle).
The gradle version is defined in gradle/wrapper/gradle-wrapper.properties.
Use:
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
For automatic update, you may set the version in Android Studio > File > Project Structure > Project > Android Plugin Version
Please note that you might also need to update Gradle Version. For gradle and gradle plugin compatibility, you may refer to the docs.
Sync gradle afterwards. This will automatically set the distribution URL as well.

Categories

Resources