Build failed, Cause: error reading zip file - android

My android studio was running perfecly yesterday, but today when I started my android studio and want to run an app on mobile the following error occurred,
I searched on the internet and stackoverflow but no solution is useful
I even manually downloaded the gradle-4.6-all.zip from the gradle/distribution and pasted in ~\.gradle\wrapper\dists, but the error still there.
kindly help me with this.

The error occurs because you don't have unzipped gradle files in ~\.gradle\wrapper\dists directory.
Extract the zipped gradle-4.6-all.zip and extract it in
~\.gradle\wrapper\dists directory.
Alternatively ,Android Studio will automatically use the Gradle wrapper and pull the correct version of Gradle. Beneath your Android Studio's project tree, open the file gradle/wrapper/gradle-wrapper.properties. Check for this entry to be:
distributionUrl=http\://services.gradle.org/distributions/gradle-4.6-all.zip
Clean rebuild the project.
Download Link for Gradle Versions: http://services.gradle.org/distributions/
References:Manually install Gradle and use it in Android Studio

Related

How to open Gradle project in Android Studio (fixing "gradle sync fails error") - error in opening zip file

I have been trying to run my project using the android emulator but everytime i try i get an error:
error reading C:\Users\ASUS\.gradle\caches\transforms-2\files-2.1\34085af895daa23049fd0af188e6a001\drawerlayout-1.0.0\jars\classes.jar; error in opening zip file
I have been trying to build the gradle but it always fails to sync
I want to be able to build the gradle and run the program using the emulator
You can delete the .jar file, download another one manually and replace it in the same directory. I'm not sure, but this might help.

Android Studio 2.2 Stuck at Building Gradle Project Info on importing existing project

I am using Android studio 2.2 on windows 10.
I am trying to import an existing android project. The problem that it took forever and still showing the message
Building 'ProjecTName' Graedle project info
after that android studio is totally getting stuck and i kill it from the task manager !
I tried the available options on Android Studio list:
Open an existing Android Studio Project
Import Project (Eclipse ADT, Gradle, etc.)
There is downloading of Gradle going on at the background. Just wait for it to finish.
Just Remove Gradle files from your project folder and retry.
Hope this will help.
I also had the problem.
I downloaded the gradle 3.5 binary distribution zip file, deleted the gradle folder from my project, then went to settings of Android Studio, checked "Offline work", used "Use local gradle distribution" and set the path of unzipped gradle folder
on the "Gradle home" and "Service directory path" text fields.
Then I tried to open the project with Android Studio 2.3.
Then a message is shown and I pressed cancel to manually configure the gradle, then I located the unzipped gradle folder again. This solved my problem.
Try the following :
1> Try Removing(Deleting) the gradle files from the project folder and then re-try.
2> Try to go into the android studio and then Files>Invalidate Caches/Restart and then try.
3> If the above two don't work do check the gradle,android Studio versions and see if those need updating.
4> Above 3 usually work for me , if it still persists, then you need to check the dependencies for the project. Also try importing some other project and if the same issue occurs, try a new installation of a STABLE version of the android studio.
Try to remove C:\Users\User.gradle
I had deleted all gradle folder and copied it from another project and pasted it, this worked for me
The above answers didn't work for me well.
I have several projects with different gradle versions, and whenever I tried to open a project the Android Studio started downloading its gradle in the background.
So, things to do before importing old projects to new Android Studio / Gradle.
In file 'build.gradle' replace old line with "classpath 'com.android.tools.build:gradle:2.3.3'"
(Assuming 2.3.3 is the latest. You can check this in your newly/recently created project)
In file 'gradle/wrapper/gradle-wrapper.properties' replace old line with 'distributionUrl=https://services.gradle.org/distributions/gradle-3.3-all.zip'
(Assuming 3.3 is the latest. You can check this in your newly/recently created project)
Now when you'll import, it wont download other gradle version.
I did find-replace for the above lines in my whole directory containing all my old projects, using Notepad++.
Actually the real Problem is that the studio is downloading gradle files throught internet and sometimes it is not able to do so, then it stucks but we can manually fix it through-
Download Gradle Files according to your android Studios version.
You can download gradle files through-https://services.gradle.org/distributions/
See your Gradle vesrion through-https://developer.android.com/studio/releases/gradle-plugin.html in the Update Gradle area.
Download the Gradle and paste it into- c:/Users/username/local/.gradle
and this is It!!!
I found that my gradle files had the gradle version set 2.1.0. So I opened the files in wordpad and first changed that to 3.3 And then it worked fine for me.
And in the gradel-wrapper.properties:
From distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
To distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
Hope that will solve the problem
This worked for me.. Will work for you for sure.
step 1: Delete "only" the Gradle "folder" from your project folder.
step 2: Import your project from Android Studio & a dialog box will appear "press
Ok to use..., or Cancel to... ". Press "Cancel" & locate the path where you have downloaded the latest Gradle File (C:/Gradle/gradle-3.5 ,in my case).
Step 3: it will give an error saying that "no cache version for....". So now check which version of com.android.tools.build:gradle: you have.. so check the path "C:\Program Files\Android\Android Studio\gradle\m2repository\com\android\tools\build\gradle" and select the latest version (2.3.2 in my case). So now, go to Gradle Scripts-> build.gradle(android) in Android Studio and change the dependencie's classpath to (classpath 'com.android.tools.build:gradle:2.3.2')in my case
step 4: Click on "try again". Then it'll ask for upgrading tools, upgrade it by clicking on it & then you're done..
Congrats, your Project is successfully built..
And yeah make sure that In Setting-> Build,Exec...->Gradle-> "check mark on Use local gradle distribution & offline work & Gradle home: C:/Gradle/gradle-3.5 & Service directory path: C:/Gradle/gradle-3.5 (in my case).
Deleting temp and temp% worked for me!
Download manually gradle-3.3-all.zip
and extract into /Users/[yourUsername]/.gradle/wrapper/dists/gradle-3.3-all/55gk2rcmfc6p2dg9u9ohc3hw9/

Build errors in blank Xamarin.Forms app

I use Xamarin for VS and I get 36 errors, this is the first one:
Severity Code Description Project File Line Suppression State
Error Please install package: 'Xamarin.Android.Support.Design' available in SDK installer. Android resource directory C:\Users\Cayl\AppData\Local\Xamarin\Android.Support.Design\23.0.1.3\embedded./ doesn't exist. forms.Droid
I gather it's because XF don't support the current Android Support Library I have (23.1.1), how do I fix this step by step, do I uninstall Android Support Library and get 23.0.1 from internet somewhere or what?
Those errors are due to the failure to automatically download the zip files from Google the first time (after that they are cached for project reuse).
If you have network access to dl-ssl.google.com, then cleaning and rebuilding the project "should" work. Sometimes exiting and restarting Visual Studio (or Xamarin Studio on OS-X) and then rebuilding will start the downloads again properly.
Otherwise the error message shows the download link for the zip file(s) needed and the directory that you need to manually place them in:
Example Error Message:
Please download https://dl-ssl.google.com/android/repository/android_m2repository_r22.zip and put it to the C:\Users\YOURUSERID\AppData\Local\Xamarin\Android.Support.Design\23.0.1.3 directory.
Once they are downloaded, they will be available for all future solution/projects.
It sounds like you might have a corrupt download. Please try deleting the zips folder, and any Android.Support.* folders from inside C:\Users\username\AppData\Local\Xamarin.
Then, delete the bin/ and obj/ folders from your solution's project folders, restart Visual Studio, and rebuild.

Android studio gradle deleted

I accidentally deleted some gradle files from where i Android studio is installed. I was following this tutorial to resolve another issue but it now even deleted some gradle files i cant even create a new project in Android studio. And cant build run or do anything. When i start android studio it shows me this error in following image:
If i open plugin manager it shows android support, cloud disabled like in this image:
In settings build tools it not does show gradle:
And in module settings it shows this:
Please someone guide me in this. I cant reinstall android studio, sdk and everything again as I have done many settings(installed plugins and git configs etc) in studio, so reinstalling everything is not an option. Any help?
One non-technical solution is to install another instance of Android Studio at different location on your system. You can then compare the directories of where where you deleted the files and copy over the files that are not there in your original installation.

Problems with Android Studio - "Please specify Android SDK"

I've just updated to the newest version of Android Studio, and started a fresh, empty project. After finishing the wizard, I opened the main Activity.java file, and there was a message that said:
Gradle project sync failed. Basic functionality will not work properly
I found that I should try the button Sync Project with Gradle Files. This produces another error:
Failed to refresh Gradle project. Could not find any version that matches com.android.support:appcompat-v7:+
Please install the Android Support Repository from the Android SDK Manager
I tried to open the Android SDK manager and got another error:
Please specify Android SDK
So I went into my Project Structure, which has two sections, 'app' and 'Android SDK'. Android SDK points correctly to the Android SDK directory, and app is blank.
What should I do?
I tried downloading the latest SDK bundle and pointing to that in the Project Structure instead, but that hasn't fixed the problem.
I had a similar problem. After updateing to AS 0.4.2 from 0.3.7 I received the error: "Gradle Project sync failed. Basic functionality will not work properly..."
What I did was to delete the content of .gradle folder and modify the gradle-wrapper.properties file:
distributionUrl=http\://services.gradle.org/distributions/gradle-1.9-all.zip
Now it works, I don't know if it's the solution for you, but be sure to backup files before deleting them :)
i know this answer may have been posted before but next time you get such an error after updating sdk,click on file->Invalidate caches/restart. This solution works perfectly for me.

Categories

Resources