In android studio I keep getting this error message when building.
I've tried
deleting the .gradle file multiple times and restarting the IDE but the error doesn't seem to stop.
I made sure that I've updated EVERYTHING there is in SDK's and other things it required.
I've tried several solution -
First Solution: Go to File -> Invalid Chaches/Restart...
Second Solution: First, Build -> Clean Project and the Build -> Rebuild Project
Third Solution: First close the project and remove from workspace of Android Studio, then Go to C:\Users\user.gradle then delete .gradle folder. After that Open the project again.
But none of them worked! Then i got a solution, which worked in my case, the solution is bellow -
In my case, the problem was in gradle version. Check your Gradle version File -> Project Structure(Ctrl+Alt+Shift+S) and Plugin version also.
Delete the XXX.Lock file, and rerun the project. You should be able to find the location of this .lock file in the error message
is solved mine by downloading the latest version the latest version of gradle distribution.
https://services.gradle.org/distributions/
Related
Can anyone explain to me the cause of this error? I know what is dexpath and dex class in android and how to fix this error. but don't know what is the cause of this error popping up every now and then.
This error occurs when
I transfer my project from one pc/laptop to another pc/laptop.
Whenever I've updated my android Studio lets say from AS 2 to AS 3 canary or stable release.
Uninstall and reinstall the Android studio and try opeining the Project again.
How I'm Fixing it:
Just remove all the dependencies and everything related to DEX Class file from gradle and sync it and then revert back to gradle settings with all the DEX file and dependencies added and Sync again. VOILAAA ..
And this is really annoying. How I can avoid this issue for my other projects without going through all this gradle sync tweak.
I had the same issue with moving projects to different system. when you move your project folder just leave out the build folder and you'll not see the error next time.
The error says a lot more then just class not found exception in the log. The path of the files/ app-parts.apk gets invalid when you move your project to a different system.
Just don't copy or just rename the old build folder to something else and open your project in AS. Build->CLEAN , BUILD->REBUILD and everything will work.
Happy Coding..
I am facing Gradle cache error and I don't know how to tackle it. I have attached the error snap with my question below. I tried different solutions posted at stack-overflow but none of them worked. Anyone suggest me a solution Any additional suggestions would be helpful.
e.g Error: Failed to open zip file.e.g
Error: Failed to open zip file.
Download the latest gradle package from this directory
Extract it and put it somewhere (for example f:\gradle-1.10)
Go to your Android Studio and load your project then open File->Settings->gradle, in this page click on Use local gradle distribution.
Type your gradle folder address there.
Its because your gradle directory is not the directory of your gradle, to check go to android studio open your project then open File->Settings->Build,Execution, Deployment->Gradle
https://i.stack.imgur.com/wVFyh.png
Hey not necessary to set gradle manually. i have also faced this issue but i deleted all files in gradle folder path "C:/Users/username/.gradle/"
simple steps follow
first goto path "C:/Users/username/.gradle/"
delete all files in above path.
open android studio and sync gradle or build again or create new project.
it will be auto downloaded new gradle version files and auto build.
*Make sure you your gradle settings like this
- checked "Use default gradle wrapper(recommended)
- unchecked offline work
You can download manually but this is another solution:
Change "https" to "http" on 'gradle-wrapper.properties' in root project.
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
to,
distributionUrl=http\://services.gradle.org/distributions/gradle-3.3-all.zip
first :i tried to delete the .gradle folder from project it doesn't
work;
second: i tried use the old version gradle ,but studio force me to
use gradle-3.3,so it confused me long time;
third:I noticed the tips unzip exception"java.util.zip.ZipException:
error in opening zip file", I tried to unzip the file by handset's
really can't unzip, so the problem must happen in the download
process.
solution: I copy the file "gradle-3.3-all.zip " from my colleague who build success,and replace mine in such path ".gradle/wrapper/dists/gradle-3.3-all/55gk2rcmfc6p2dg9u9ohc3hw9/gradle-3.3-all.zip "
If you want to use gradle wrapper - delete anything under:
.gradle/wrapper/dists/
and refresh gradle.
The gradle wrapper will download from scratch and everything should work fine.
I solved this problem with the installation of Gradle using HomeBrew on Mac. If you type gradle -v in terminal and shows command not found: gradle, then I think you can use this way to solve this problem on Mac:
First install the Gradle with Homebrew: brew install gradle
Then go to Android Studio, open Android Studio->Preferences->Build,Execution,Deployment->Gradle, under Project-level settings check: Use local gradle distribution and set Gradle home with: '/usr/local/Cellar/gradle/3.5/libexec' (3.5 is my gradle version)
Try again, and if the version is not correct, you can manually download the specified version from gradle website (the version specified in the file <your project dir>/gradle/wrapper/gradle-wrapper.properties: distributionUrl=<url>), extract the downloaded zip file to the location and set the Gradle home to it in Android Studio.
Hope that helps.
From my MAC i just go to the gradle folder (/Users/USER/.gradle) > wrapper > dist and delete the gradle folder with the problem. Then go to studio and re-download the gradle file.
In my case, I changed distributionUrl in gradle-wrapper.properties from
https\://services.gradle.org/distributions/gradle-6.5-bin.zip
to
https\://services.gradle.org/distributions/gradle-6.5-all.zip
cd /root/.gradle/wrapper/dists
ls
gradle-5.6.4-all gradle-6.5-all gradle-6.6.1-bin
gradle-6.1.1-bin gradle-6.5-bin
for example (gradle-6.1.1-bin) :
rm -R gradle-6.1.1-bin
I can not build any android project in Android Studio. Recently Android studio was updated to 2.3 as well as the gradle version. I think somewhere the update has messed up I am not sure where it is. I have deleted .gradle directory from the home folder several times by now. Changed the distributionUrl to older version of gradle. But the problem persists. Where to look at what is going on? How to solve this issue?
The reason behind taking too much time on refreshing gradle project is, it was downloading gradle distribution and each time and for some network issue the download was never being completed. The zip file for gradle distribution was 91MB. So the network error + slow internet connection made it impossible task for my Android Studio.
I found two solution for this:
First approach is we have to download the gradle distribution manually from services.gradle.org/distributions. Then follow the process of this answer of the question - Android Studio Stuck at Gradle Download on create new project.
Second approach is somewhat like the first approach but less complex. Download gradle distribution. Extract it somewhere. Then go to:
File > Settings > Build, Execution and Deployment > Gradle
Check Use local gradle distribution. Set the Gradle home to the folder we have extracted.
I had the same problem
What I have done is
1.Close your project
2.Delete folders of .idea , .gradle, gradle folders from my project(not from home). then
3.File=>open your project
press ok in the dialogue box it will automatically set the gradle for you.
or
You can specify gradle path
settings->build excecution deployment->build tools->gradle set your
gradle home path to your downloaded gradle
I faced this case because of slow internet, Each time while beginning with the project, it downloads the gradles taking more time.Finally refreshing complete after waiting for 10 minute.
Just today I was on Android Studio working on a project, when my computer suddenly crashed in the middle of an upload.
Ever since I rebooted it, the Gradle Console has been returning this same error:
com.google.common.util.concurrent.UncheckedExecutionException:
java.lang.RuntimeException:
com.google.gson.stream.MalformedJsonException: Use
JsonReader.setLenient(true) to accept malformed JSON at line 1 column
1
I cannot make any sense out of this error, and could not find anyone else with the same issue. They always tend to differ in weird ways, and none of them are the error I have. I have not edited any of the JSON files (because I don't know where they are located).
Clean your project using :
Go to Build -> Clean Project
Then Rebuild again using :
Go to Build -> Rebuild Project
I hope it might help you !
File -> Invalidate Caches/Restart
you can try this
Firebase android Projects,
If you are using Firebase in your Mobile app.
download the google-services.json file and put it inside the /app folder and run the project again.
I'm using ant command line to build an android project with an external library. (For some reason, I can't make it into a jar to put in libs/)
After completing all the steps of android update and reference link for the project and the lib project, the error of "invalid resource directory name: ./bin/res\crunch" pops out when running "ant release". I know it is a common error but failed to solve it after doing intensive research and trying out all the solutions, including
1) project->clean
2) delete ../bin/res/crunch. (it will re-appear and create the trouble)
3) change android version or SDK version to higher one
Any suggestion? Thanks!
A cleaner solution is to clean before building:
ant clean
ant release
You don't really have to copy things from the 'crunch' directory to the 'res' directory, since these are generated as part of the build anyway.
It appears that the root cause of this problem is incompatibility between ADT v.22.2.1 and ANT.
Related threads:
https://plus.google.com/+AndroidDevelopers/posts/hNZNjqKLpny
https://code.google.com/p/android/issues/detail?id=60496
Finally I figured it out: copied everything from bin/res/crunch folder and pasted it in res and then deleted the crunch folder. If the library project is modified, the error will reappear. Redoing the procedure above will fix it again.