I downloaded an open source game "ChaseWhisplyProject" source code from Github.
I imported the project in my Android Studio (Version 1.5.1).
It shows following error message:
Error:Failed to open zip file.
Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)
Re-download dependencies and sync project (requires network)
Re-download dependencies and sync project (requires network)
I changed all the dependency versions to latest one bu still it is showing the same message.
It has two modules under the main project 1) BaseGameUtils & 2)ChaseWhisply.
The above modules are not shown in bold letters (I think it should be shown in bold letters like module "app").
Following are the gradle files.
1) Root Gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
allprojects {
repositories {
jcenter()
}
}
2) BaseGameUtils Module Gradle
apply plugin: 'com.android.library'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
}
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
}
}
dependencies {
compile 'com.android.support:support-v4:23.1.1'
compile 'com.google.android.gms:play-services:8.4.0'
}
3) ChaseWhisply Module Gradle:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
}
}
apply plugin: 'com.android.application'
dependencies {
compile 'com.android.support:gridlayout-v7:23.1.1'
compile 'com.android.support:support-v4:23.1.1'
compile 'com.android.support:cardview-v7:23.1.1'
compile 'com.nineoldandroids:library:2.4.0'
compile project(':BaseGameUtils')
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
lintOptions {
// TODO fix and remove !
disable 'MissingTranslation', 'DuplicateIds', 'ExtraTranslation'
}
defaultConfig {
minSdkVersion 14
targetSdkVersion 23
versionCode 22
versionName "0.3.6"
}
}
4) Settings.gradle
include ':ChaseWhisply', ':BaseGameUtils'
What is wrong over here? Please help.
While importing a libGDX project I got the same message from Android Studio 2.2.
Went to File->Project Structure then selected Project and set
Gradle version
and
Android Plugin Version
to values identical to another project I had recently created with Android Studio 2.2 and updated SDK. Could then sync gradle. Did Build->Build Clean with no issues. Then did Run->Clean and Rerun and project ran fine.
Hope this helps.
It basically means that the gradle zip file in the cache folder is corrupted, if you don't want to change the version like the up-voted answer then you must delete the folder for your gradle version you're using for this project from the below path.
Then just retry the sync and android studio will download it again
C:\Users\ [user here] \.gradle\wrapper\dists
ex: if you're using 3.3 for this project you'd be deleting the folder
C:\Users\[user here]\.gradle\wrapper\dists\gradle-3.3-all
I was also facing the same issue. The solution worked for me was go to "gradle\wrapper\dists" and deleted the folder "grade-4.10.1-all" folder and downloaded the same version after that i pasted the extracted folder in same address.After that I again synchronized the android studio. I worked for me.
I face the same problem and I search for it and found a best solution and i works for me:
Manually download Gradle 3.3 binary (direct link: https://services.gradle.org/distributions/gradle-3.3-bin.zip)
Open your android studio root directory, and extract the zip to the gradle folder (for example: program files/android-studio/gradle/gradle-3.3)
Open Android Studio, go to File->Settings-> (Build, Exectution, Deployment) >Gradle and set "Gradle home" to point your new gradle-3.3 folder.
Apply and sync.
May be incompatible with Gradle and maven version
delete project dir/gradle/wrapper
put a right version gradle into it
run again
change the gradle-wraper-properties distributionUrl to your local downloaded gradle such as
distributionUrl=https://services.gradle.org/distributions/gradle-3.3-all.zip
I solved this issue by this following steps
1.C:\Users\System name.gradle\wrapper\
2.Inside wrapper folder u will find grale file with some version, You just have to delete it
3.Come/Go to android studio and Go to File->Sync project with Gradle Files.
4.Android studio automatically download the require gradle file.
5.And now go for coding
The close android studio then goes to the directory and you will find this type of folder. I saw in my pc. after deleted then clean project and sync. its works fine.
you just delete from this directory
C:\Users\ [user here] .gradle\wrapper\dists
if you use 3.3 version in android studio. you can see like this
C:\Users[user here].gradle\wrapper\dists\gradle-3.3-all
Well, It's a bit late, but usually happens when something went wrong in Android Studio's initial launch (eg. system crash, connection loss or whatever). We can call it bad programming or lazy QA.
To fix this close Android Studio and delete everything from the following directory. Don't worry files will be downloaded on next launch.
For Windows: C:\Users\your-username.gradle\wrapper\dists
For Linux: ~/.gradle/wrapper/dists
For mac: ~/.gradle/wrapper/dists
You can also Gradle manually to fix this issue, But it's better to let Android studio does this work. .
Clean Project is a way to go. After you clean project, make sure you rebuild it. Usually it solves the gradle issues for me.
In my case I was running IntelliJ IDEA as non root user.
If you want to use the new features, you should not revert it to the old version, just delete the directory ~/.gradle recursively, then restart Android Studio.
Update your gradle version and update with required version of gradle and syn your project.
https://services.gradle.org/
First of all, open your gradle-wrapper.properties file from the project then note down the version of the Gradle.
It could be like this:
distributional=https\://services.gradle.org/distributions/gradle-6.5-bin.zip
So, here my Gradle version is 6.5. It could be different in your case.
After this, open file explorer and open your project folder. There you will be having the Gradle folder open it, inside it the version will be mentioned of your previous Gradle.
Now you will have to download the Gradle file according to the wrapper.properties(for example nothing but 6.5 version).
You can download it from here
Extract it
paste it to the Gradle folder
open your project > file > settings > Build, Execution, Deployment > Gradle, then select the newly downloaded Gradle file in the Gradle user home.
Then run your project.
This worked for me - go to https://gradle.org/releases/ and download latest stable version (binary-only works fine). extract and insert into C:\Users\OWNER\.gradle\wrapper\dists folder.
Open Android Studio settings > Build, Execution, Deployment > Gradle, use gradle from: specific location.
The following steps solved my problem :
1.C:\Users\System name.gradle\wrapper\
2.Inside wrapper folder u will find grale file with some version, You just have to delete it
3.Come/Go to android studio and Go to File->Sync project with Gradle Files.
4.Android studio automatically download the require gradle file.
5.And now go for coding
Related
When I import an Eclipse project into Android Studio, I got this problem:
Gradle 'XNote' project refresh failed
Error:Could not determine the class-path for interface com.android.builder.model.AndroidProject.
Anyone knows why it happened? Thanks!
Just now i am facing the same problem.
1.Check classpath in build.gradle file.
change to
classpath 'com.android.tools.build:gradle:2.3.0'
then go to gradle-wrapper.properties, and change distributionUrl
distributionUrl=http://services.gradle.org/distributions/gradle-3.3-all.zip
and then rebuild the project. its help for me...
I think this will definitely helps you.
I have solved this problem.
Google doesn't update ADT any more, so when Eclipse export a project to gradle, it use an old gradle plugin version that Android Studio doesn't support.
First, you should check the version of gradle plugin that you have installed.
Open Android Studio's installation directory,then open the directory \gradle\m2repository\com\android\tools\build\gradle\, you will see all version you have installed.
Then open Android Studio, open tab 'Project -> Gradle Scripts', Edit file build.gradle, change the gradle plugin to newest version you have installed, such as 2.3.0:
[OPTIONAL] This step is not necessary, but if you do not do this, you may see this problem:
A problem occurred evaluating root project 'XXX'.
> org/gradle/initialization/BuildCompletionListener
Check the newest version of gradle you have installed at C:\Users\YOUR USER NAME\.gradle\wrapper\dists.
Then open tab 'Project -> Gradle Scripts', edit file gradle-wrapper.properties, modify the gradle version(attention: gradle, NOT gradle plugin) to the newest at the last line.
Finally, click Build - Clean Project, done!
If it still warning "Gradle project sync failed...", just click Try Again!
AT THE END, SOMEBODY HELP ME TO TRANSLATE MY ANSWER TO REAL ENGLISH THAT NO grammatical mistakes!!!
Just Update two things:-
1) Update your Build.gradle to
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
}
2) Update Gradle-wrapper.properties: (Change Android mode > Project mode then Extend Gradle and open Gradle-wrapper.properties)
Replace distributionUrl=http\://services.gradle.org/distributions/gradle-1.12-all.zip
By
distributionUrl=http://services.gradle.org/distributions/gradle-3.3-all.zip
This always resolves the issue. may it usefull for you
I got it working after upgrading build tools to version 25.0.0 in build.gradle:
buildToolsVersion '25.0.0'
And change project to use newest gradle version 3.3 with default gradle wrapper (File -> Settings -> Gradle)
In my case I removed folder .idea from the project and then restarting the studio automatically manages to all the required folder and gradle work.
First, delete your .gradle folder in the home directory then restart Android Studio.
Palanivelraghul was right. A Studio has to download the old version. Then it presented 3 different options after it was complete.
Choose the top option ~"Sync with 3.0.1".
Event Log:
Gradle sync started > Project setup started > Gradle sync finished > Executing tasks:
[:app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:mockableAndroidJar] > Gradle build finished.
I have been struggling with this gradle for the last one week. None of the earlier questions on gradle issue could solve my problem.
Things I did :
Download the latest gradle. I did it by changing the path at distribution URL in gradle-wrappper properties.
(It will download the latest one say 2.14. but, When I create a new project, It will be set to 2.10 and then back to same dirt)
Should I download the gradle for every project I create ? ... Help me fix this.
Thanks in advance :)
This is the error when I create a new project
Use the latest version of gradle with in build.gradle.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
}
}
Don't confuse gradle and the android plugin for gradle.
1) You can define the gradle distribution used by a project in the file
gradle/wrapper/gradle-wrapper.properties
For example:
distributionUrl=http\://services.gradle.org/distributions/gradle-2.14-all.zip
Each project can use a different version. You will find the distributions file inside \user\.gradle\wrapper\dists folder.
2) Gradle is a build tool, but it requires specific plugin to work.
Android Tool Team is releasing the Android plugin for Gradle.
You can define the plugin inside the build.gradle file in the project.
For example:
classpath 'com.android.tools.build:gradle:2.1.3'
Each project (or module) can use a different version.
Also go to File > Settings > Builds,Execution,Deployment > Build Tools > Gradle
and set Use default gradle wrapper
I have an Android App in Android Studio. When I build project with Gradle File,it gives me one error at compile time.
Error Report:
Error:org.gradle.api.internal.changedetection.state.DefaultFileCollectionSnapshotter$FileCollectionSnapshotImpl cannot be cast to
org.gradle.api.internal.changedetection.state.OutputFilesCollectionSnapshotter$OutputFilesSnapshot
Please Give me solution about this error.
1.delete {project dir}/.gradle/{gradle distribution version dir}
{gradle distribution version dir} is whatever the gradle distribution version you use (ref: https://developer.android.com/studio/releases/gradle-plugin.html#revisions). For example, it can be "1.9" or "2.10" or some other version number.
2.Sync Project with Gradle File
This is what worked for me:
Android Studio -> File -> Invalidate Caches and Restart
Stoping the gradle daemon worked for me.
go to terminal and run ./gradlew --stop
Rebuild the project.
For me, I have tried to:
(Doesn't Work):
invalidate caches.
stop third-party plugins.
remove gradle repository.
remove {project dir}/.gradle/2.*(which are not current gradle version)
(Work):
Finally, the answer is like #MAC113's,
delete {project dir}/.gradle/2.10 (2.10 is my current gradle version)
None of those solutions working for me. I ended up by:
Clone my project to a new folder
Remove .gradle, .idea folders
Add as a new project (File > Open > [new folder])
It works! It's a weird issue that I've ever met.
Easy solution! Just fixed on my side. It was a project exported from Unity Studio.
After exporting from Unity, the gradle was like com.android.tools.build:gradle:2.1.0
I then changed it to com.android.tools.build:gradle:2.2.0 and it worked.
Also never forget to change the repositories from mavencenteral to jcenter().
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
}
}
If you using GreenDao You should update it to the lastest version
classpath 'org.greenrobot:greendao-gradle-plugin:3.3.0' // add plugin
implementation 'org.greenrobot:greendao:3.3.0'
Deleting .gradle folder works for me
There is a new Android Studio update: https://sites.google.com/a/android.com/tools/recent/androidstudio030released
The link says:
The improved performance is made possible by changes in Gradle 1.8 and
Android Gradle plugin version 0.6.+
So I changed my dependencies like this:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.6.+'
}
But I don't know where I can change the Gradle 1.6 to 1.8 ...
And when I compile the app I've got this error:
Gradle: A problem occurred evaluating project.
Gradle version 1.8 is required. Current version is 1.6
Where can I change the version ?
Thanks in advance :)
I am not sure if this will help you but here is what fixed it for me:
Open up this file in your project:
<Project>/gradle/wrapper/gradle-wrapper.properties
Edit the distributionUrl line and set it too:
distributionUrl=https\://services.gradle.org/distributions/gradle-1.8-all.zip
Rebuild your project.
Update: You might want to use gradle-2.8-all.zip now.
I had same problem. Try to remove directory 'gradle' in project directory and then rebuild project. It helped me.
The Android Studio ask you for download and install the Gradle version 1.8 for you.
Also the Android Gradle plugin version 0.6.2 has an issue and not works properly.
As said on the official page use the version 0.6.3:
dependencies {
classpath 'com.android.tools.build:gradle:0.6.3'
}
More info:
http://tools.android.com/knownissues
You should use the following in your build.gradle:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.7.+'
}
}
Edit:
Nowadays 0.9.+ is the most up-to-date gradle plugin.
The Android Gradle 0.6.2 plugin that was published on Maven Central. Edit your build.gradle file and instead of depending on "0.6.+", depend on "0.6.1".
All other solutions are incomplete and non-working. Here's a step-by-step that worked for me.
I updated the gradle plugin in build.gradle to 0.7.+
dependencies {
classpath 'com.android.tools.build:gradle:0.7.+'
}
But when using the gradle plugin 0.7.+, Android Studio needs Gradle 1.8. So, you have to update Gradle from 1.7 to 1.8.
This was done by going to
Tools -> Android -> Sync Project with Gradle Files
It forces Android Studio to give out Error message you see on http://tools.android.com/recent
In the error message you have to click the part "Fix Gradle wrapper and re-import project". I restarted, not sure if this make a difference.
So far everything seems to work. I can create new projects and it build fast, without errors, but the gradle has still 0.5+.
Looks like, I had to change it manually for every new projects. This is what I thought, because I didn't get any error or information from this installation to fix it. (Mac).
Than I went to my Windows installation, which had still Android Studio version 0.2.13 and
tried the same procedure, I used with the updated version, changed the build,gradle and used Synch Project with Gradle Files. This gave me a total different information:
Gradle version 1.8 is required. Current version is 1.7. If using the gradle wrapper, try editing the distributionUrl in
C:\Documents and Settings\Owner\Start Menu\Programs\Android Studio\gradle\wrapper\gradle-wrapper.properties to gradle-1.8-all.zip
Turned out, I have a gradle-wrapper.properties file in every project (in gradle/) but I don't have any gradle-wrapper.properties file at the location Android Studio gave me.
When you open the gradle-wrapper.properties file from your project, it will properly look like this:
#Sun Oct 20 03:35:31 CEST 2013
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=http\://services.gradle.org/distributions/gradle-1.7-bin.zip
To change the gradle-1.7-bin.zip into gradle-1.8-rc-1-bin is possible but not the solution I was looking for.
Check out if Andoid Studio already downloaded the gradle plugin 1.8
Directory of C:\Documents and Settings\Owner.gradle\wrapper\dists
2013-10-13 06:24 <DIR> .
2013-10-13 06:24 <DIR> ..
2013-10-04 18:17 <DIR> gradle-1.6-bin
2013-10-13 06:24 <DIR> gradle-1.7-all
2013-10-04 12:23 <DIR> gradle-1.7-bin
2013-10-04 18:26 <DIR> gradle-1.8-rc-1-bin
0 File(s) 0 bytes
6 Dir(s) 81 945 972 736 bytes free
Now I create a new gradle-wrapper.properties file in
*C:\Documents and Settings\Owner\Start Menu\Programs\Android Studio\gradle\wrapper*
#Tue Oct 20 06:35:40 CEST 2013
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=http\://services.gradle.org/distributions/gradle-1.8-all.zip
This did the Trick. Now, after updating to 0.3, every new project gets a build.gradle with
dependencies {
classpath 'com.android.tools.build:gradle:0.7.+'
}
and a gradle-wrapper.properties file in gradle/ with
distributionUrl=http\://services.gradle.org/distributions/gradle-1.8-bin.zip
Credits
I took several steps including: downloaded the gradle-1.8-all.zip file and placed it in a new directory off of my user home directory (Windows-7) and named the directory "gradle-1.8". For good measure, I also unzipped the download in this new directory. I also added a user environmental variable "GRADLE_HOME" with a pathway to this new directory.
I manually edited the "build.gradle" file in the project's top-level directory and entered:
dependencies {
classpath 'com.android.tools.build:gradle:0.6.3'
}
When Android Studio opened the existing project and I did a build or tried to run it, I got the subject error. The final solution, as mentioned by others, was a several step process:
I removed both the "gradle" and the ".gradle" directories.
I rebuilt the project which recreated the ".gradle" directory but not the "gradle" directory. Then, I closed the project and used "File/Import Project" to load the project again. And, I used the "Use customizable gradle wrapper" as suggested.
This worked. The "gradle" directory was created again in the project's top-level directory. The project builds clean and runs. It would be nice to have step-by-step upgrade instructions for these updates.
Old question but just in case someone runs into the same issue I had with upgrading.
If you have setup gradle for offline mode, it doesn't update the wrapper properly. Turning off offline mode (Preferences->Gradle->Offline work) then clean/rebuild pulled in the new gradle version. This assumes that gradle-wrapper.properties file has been updated.
Similar Issue :
Just updated android studio :p
Help -> Check for Update...
This is a late response, but in case anybody's run into a problem of the gradle version in their ionic project being overwritten by an older one by AS, just remove the android platform from your ionic project and then re-add it. Evidently, installing Gradle is part of that command, so you'll overwrite the overwrite, and get the version you need to run ionic build android from within your Ionic project's root directory.
Although, WARNING: Removing the Android platform, and then re-installing it, might wipe the splashscreens and icons that you'd had in your resources folder. And by "might," I mean that it's happened every time that I've done it (which makes sense, since the resources folder is inside of the android folder that you're removing/re-intalling). Perhaps a more eloquent command line input could reinstall the android platform while leaving the resources folder alone, but, in any case, make sure to copy the directory with your custom splashscreens and icons to a new one before running the re-install.
You can download the latest Gradle file from This link
You can then add it to your File -> Settings -> Build, Execution, Deployment -> Gradle path and the sync the project
I'm trying to add a .jar library to my project into the /libs folder. Here is my grade.build:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.4'
}
}
apply plugin: 'android'
dependencies {
compile files('libs/android-support-v4.jar', 'libs/java-api-wrapper-1.2.0-all.jar')
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 15
targetSdkVersion 16
}
}
After I add that, I build my project and there are no errors. But when I try to use the class in my code private ApiWrapper wrapper, I get an error:
Gradle: error: cannot find symbol class ApiWrapper
I can't quite find where the error is. Is my grade.build not ok, or am I supposed to build it some other way?
Using the command line, in the root of your project, run :
./gradlew clean && ./gradlew build
Then recompile your project in studio and you should see your new lib.
Set minifyEnabled to false for all your library projects in build.gradle.
See accepted answer by Scott Barta in this thread.
See accepted answer by Scott Barta in this thread
Goto File ⇒ Invalidate Caches & Restart
Solved my problem
As first option, i think will be enough Syncronizing the Project with Gradle Files.
Another option, from the command line, run the batch file gradlew.bat located inside your project folder:
./gradlew clean && ./gradlew build
I had a similar situation where Android Studio couldn't find a library that definitely existed. Even though I was able to compile my project in Android Studio, run it from Android Studio in the emulator or on a physical device, and build it from the command line using gradlew, the Android Studio IDE complained Cannot resolve symbol 'ConstraintLayout'. I believe I had imported the library correctly because I followed Google's instructions: https://developer.android.com/training/constraint-layout/#add-constraintlayout-to-your-project.
Anyway, I ended up solving the problem as follows:
Close Android Studio
Delete the .idea folder in the project's directory
Open Android Studio
Re-import the project so Android Studio can regenerate the .idea folder
This in-fact solved the problem. I believe Android Studio somehow corrupted the .idea folder when I had done "Android Studio" > "Check for Updates" earlier in the day.
Go to the Android studio File and press Invalidate Caches/Restart. This worked for me to find the library