Android studio: Project refresh failed.. error in opening zip file - android

I've installed Android Studio on my laptop and also run the updates from 0.52 to 0.61
After creating a new project or opening a sample project that I've downloaded it displays this error:
Gradle '{ProjectName}' project refresh failed
Error:Cause: error in opening zip file
I couldn't find anything related to this specific error on Google or anywhere else on Stackoverflow.
Please help?

download manually
http://downloads.gradle.org/distributions/gradle-1.12-all.zip
and paste: (not unzipping)
C:\Users\ (USER NAME) \ .gradle\wrapper\dists\gradle-1.12-all[hash code]/
C:\Users\ (USER NAME) \ .gradle\wrapper\dists\gradle-1.12-all[hash code]/gradle-1.12-all.zip
update
For Mac OS X and Other Unix based OS, the path is
~/.gradle/wrapper/dists/gradle-1.x/[hash code]/

I had the same problem after updating Android Studio from 2.2.3 to 2.3; Here is the solution that worked for me:
1) In your project open 'gradle-wrapper.properties', change the 'distributionUrl' value
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
2) In you project open the project's 'build.gradle' file, and change the classpath
classpath 'com.android.tools.build:gradle:2.3.0'
This is the latest gradle setting.
Hope this work.
NOTE: The version of the gradle depends on your android studio version. So change the version(as in he code) according to that.

I fixed this issue by...
Going to Settings... > Gradle
Selecting "Use local Gradle distribution."
Pointed it to my Gradle zip file: home/kersting/.gradle/wrapper/dists/gradle-1.12-all/6vpvhqu0efs1fqmqr2decq1v12/gradle-1.12
It should be something similar for you if you downloaded Gradle which you should have when you downloaded Android Studio. Be careful, the .gradle file may be hidden. I found it through the terminal, but "ls" didn't reveal it.

Related

Android Studio: Unable to build app due to gradle distribution url error

I know this question has been asked before but I haven't been able to fix the issue. I am running Android Studio version 3.1.4. I am trying to run an app that I cloned from a Github repository. But even before I try to run it, I get this error:
my-app: sync failed
Cause: https://downloads.gradle.org/distributions-snapshots/gradle-4.4-20171031235950+0000-all.zip
How do I fix this error? Thanks in advance.
You can check and change the distribution url in the properties file $rootDir/gradle/wrapper/gradle-wrapper.properties. See property distributionUrl.
Value should be something as follows (update the gradle version depending on your Android Studio version)
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
I've encountered a similar error when I tried importing the Sunshine project from the Udacity Android development course. I fixed the issue by downloading the mentioned zip file and extracted it to the C:\Users\<username>\.gradle\native folder.
Then in Gradle settings, use local Gradle distribution and set the Gradle home path to the downloaded gradle folder.
Check this video for more information
You can fix it by the following steps: (currently using Android 3.6.3)
This worked for me.
Exit android studio then make the below changes.
Go to C:\Users\UserName.android and rename the build-cache folder to build-cache.bak.
Go to C:\Users\UserName.AndroidStudio3.6\system and rename these folders:
caches to caches.bak
compiler to compiler.bak
compile-server to compile-server.bak
conversion to conversion.bak
external_build_system to external_build_system.bak
frameworks to frameworks.bak
gradle to gradle.bak
resource_folder_cache to resource_folder_cache.bak
Open the Android Studio and open your project again.
If the folder is not in the Android3.6 folder, move to the next step.
Find the Gradle version from the gradle-wrapper.properties file
Download the Gradle bin file from internet, then extract it.
File menu-->Settings-->Build & Tools-->Gradle-->Use Gradle from: From
drop down select a specified location and browse to the location
where you have saved the Gradle bin zip file. (Default settings is use from ;gradle-wrapper.properties' file)
4.File menu-->Invalidate caches and re-run
[Gradle properties file]
[Gradle settings]

How to solve Specified AAPT2 executable does not exist on Android Studio 3.2

I've an issue with Android Studio. I'm trying to use it on Windows but I've trouble during the project's build process.
First, notice Android Studio is installed on my secondary HDD.
When I try to build/run my project I get this error:
Specified AAPT2 executable does not exist:
C:\Users\Rémi\\.gradle\caches\transforms-1\files-1.1\aapt2-3.2.0-4818971-windows.jar\35960bdffa2420a45dff6ec260c07fa9\aapt2-3.2.0-4818971-windows\aapt2.exe
And indeed there is no aapt2.exe here.
But I've found this .exe here:
H:\Logiciels\AndroidStudioSDK\build-tools\28.0.2\aapt2.exe
and a previous version here:
H:\Logiciels\AndroidStudioSDK\build-tools\27.0.3\aapt2.exe
I've tried to fix this issue by changing the build tools version by setting File > Project structure > Modules > App > Build Tools Version. This option was empty and I chose 28.0.2 but that doesn't change anything.
Thanks for reading.
P.S.: This question is not the same. My error is different and I have google() in my Grable file.
I solved it by deleting the directory under which it expected the aapt2 executable, e.g. C:\Users\support\.gradle\caches\transforms-1\files-1.1\aapt2-3.2.1-4818971-windows.jar\4c1f5b7dca1d5d378360be7f3fd9726a\aapt2-3.2.1-4818971-windows and then did a clean in Android Studio Build>Clean Project.
Afterwards it appears to have downloaded this again, with the missing executable, and now works perfectly.
I had the same issue. I resolved it by opening my file browser and navigating to this folder
C:\Users\(My User Name)\.gradle\caches\transforms-1\files-1.1\aapt2-3.2.1-4818971-windows.jar
Opening this folder and viewing its contents, I deleted the folder labeled 81c3666e327fa931c773a52e6cb0b3b7 which for you would be 35960bdffa2420a45dff6ec260c07fa9.
After this I went back to Android Studio and clicked the Build menu, and used the Clean Project option, followed by the Rebuild Project option.
I no longer get this error, or all the debug errors that say the Java package "R" did not exist.
I hope this helps.
Following solved my issue
under jar folder there are 3 folders, one of the folder consists of the aapt2.exe in it.
I copied that file to other folder where I am getting error.
ex:
path of jar: C:\Users\umabhavania\.gradle\caches\transforms-1\files-1.1\aapt2-3.2.1-4818971-windows.jar
error path: C:\Users\umabhavania\.gradle\caches\transforms-1\files-1.1\aapt2-3.2.1-4818971-windows.jar\a57a698502c21bfe8cfc3ed6eb102b39\aapt2-3.2.1-4818971-windows
copied aapt2.exe file from 57f15fb82085ec9389484ff7e041344f folder to a57a698502c21bfe8cfc3ed6eb102b39
Hope this helps..
I resolved this issue by removing that folder
Go to that path -> Delete
Ex: C:\Users\Rémi.gradle\caches\transforms-1\files-1.1\aapt2-3.2.0-4818971-windows.jar\35960bdffa2420a45dff6ec260c07fa9\aapt2-3.2.0-4818971-windows\aapt2.exe
In this go to "C:\Users\Rémi.gradle\caches\transforms-1\files-1.1\aapt2-3.2.0-4818971-windows.jar\" and delete 35960bdffa2420a45dff6ec260c07fa9
Clean Project and Build
1- enter to the file like
C:\Users\4khalil\.gradle\caches\transforms-1\files-1.1\aapt2-3.3.2-5309881-windows.jar\6abc6a09978228d11497e7ca9c3de2c9\aapt2-3.3.2-5309881-windows
then if you find aapt2.exe.dat, delete the extension .dat to be aapt2.exe
and the problem will be solved.
You can use 'invalidate cache and restart'.
In Android Studio, go to File menu -> click Invalidate Caches/Restart.
Just chnage the gradle version in your build.gradle file in android folder.
For example mine was 4.1.0, changed it to 4.1.1
dependencies {
classpath 'com.android.tools.build:gradle:4.1.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
just copy paste this file aap2.exe get it from a friend or somewhere at this location and paste it on the same folder found in yours in .gradle C:\Users\Dina.gradle\caches\transforms-1\files-1.1\aapt2-3.2.1-4818971-windows.jar\8735df2342ae4ae127451389faa5e1f1\aapt2-3.2.1-4818971-windows\
then build and then the build will complete successful.
I didn't know how to attach the file in my answer I am new to stack overflow.

Gradle connection timed out after update Android studio to 2.3

After I update android studio to 2.3, my old project is not opened in android studio shows me gradle error. And when I open a new project, that project is not build
After the new update of android studio (2.3) this is a common bug.But heres the best solution to this.Once you get a message as gradle sync failed,then its as because your gradle file got bug.
the solution is go to C:\Users\Admin.gradle\wrapper\dists\gradle-3.3-all\55gk2rcmfc6p2dg9u9ohc3hw9
here you can find a zip file : gradle-3.3-all.zip
delete all contents in that and download file from https://downloads.gradle.org/distributions/gradle-3.3-all.zip
paste this in 55gk2rcmfc6p2dg9u9ohc3hw9 folder. Then restart studio.It will be working perfectly.
If you have any other version of gradle you can find the corresponding file in https://services.gradle.org/distributions
I found it my self now, its very easy
Just need Edit "build.gradle.project" dependencies to 2.3.0 and edit file "gradle.wrapper.properties" , distributionUrl to "/gradle3.3-all.zip" and sync project

How to fix com.android.builder.internal.aapt.AaptException: Failed to crunch file?

I have the latest version of Android Studio (as of Sep 21, 2016). When I create a brand new project in Android Studio and try to build it, I am getting this build error:
Error: com.android.builder.internal.aapt.AaptException: Failed to
crunch file
H:..pathTo..\app\build\intermediates\exploded-aar\com.android.support\appcompat-v7\24.2.1\res\drawable-xhdpi-v4\abc_list_selector_disabled_holo_light.9.png
into
H:..pathTo..\app\build\intermediates\res\merged\debug\drawable-xhdpi-v4\abc_list_selector_disabled_holo_light.9.png
What does this mean? And how do I fix it?
Build log:
https://jpst.it/NCnu
Amazing. It's 2016 and Google's tool chain still has these annoying file path limitations.
Error: File path too long on windows, keep below 240 characters
Move project further up your project file path and the problem goes away!
There is a workaround. If you add the following to the project build.gradle file, inside the allprojects section, it will move the Build output files to this folder. Meaning the app will now build.:
buildDir = "C:/tmp/${rootProject.name}/${project.name}"
It does give you an additional app module at the root of the project but this is a much more convenient option than moving whole Project folder path.
I Found the same Error (Error: com.android.builder.internal.aapt.AaptException: Failed to crunch). I Copied the directory one level above. It Works!
The solution that help me was to delete node_modules folder,
remove android platform by running the command ionic platform remove android
and then go upper the project folder in system hirarchy
and then:
npm install
ionic platform add android
ionic run android
I faced this problem when trying to generate an unsigned apk using Gradle in Android Studio IDE 3.0
I solved it by creating a fresh new project and copied each file with the slightest amendment needed e.g. changing the package name, but I left the icons as they are thus I haven't added a new icon in several files like I did in the previous project.
And the problem was solved, it builds with no such error.
(However the generated apk file wasn't found in app\build\outputs\apk but inside app\build\outputs\apk\debug, but that's another problem which is not so important I hope).
I encountered a similar error. Just try to reduce the path length by moving the project folder up.
This will surely solve the problem.
Update you gradle to latest one, it solve the problem, i was also facing same problem, it work for me.
I was using classpath 'com.android.tools.build:gradle:2.0.0', then replace to
classpath 'com.android.tools.build:gradle:3.0.0' , it work for me.

Failed to create new project in android studio 0.2.3

After I updated form 0.2.2 to 0.2.3, I create new project failed.
Error message is below:
下午 08:51:58 Gradle 'NotifyViaGoogleMapsProject' project refresh failed:
The SDK directory 'C:\Program Files (x86)\Android\android-studio\bin\Program Files (x86)Androidandroid-studiosdk' does not exist.
Build file 'F:\AndroidStudioDevelop\NotifyViaGoogleMapsProject\NotifyViaGoogleMaps\build.gradle' line: 9
NotifyViaGoogleMapsProject is my project name,and my android studio is install in default path(C:\Program Files (x86)\Android\android-studio), there has no same error in 0.2.2.
I've figured out the problem.
Open 'local.properties' in your project using a text editor.
sdk.dir=..\\sdk
Save and Close
Now Import your project into Android Studio.
Make sure that the SDK folder you mention exists - I'm not sure if it is a typo or not but the path you specified is a bit weird - it should be
C:\Program Files (x86)\Android\android-studio\sdk
On the menu go to File -> Project Structure, then choose SDKs under Platform Settings. Check that the path for the Android Platform you use is correct, and if not, change it to the correct path. Also make sure that the Project is set to use the correct Android Platform.
I have the same problem.
http://i.stack.imgur.com/pPOOi.png
The SDK is correct in Platform Settings, I have no idea what's causing this problem.
http://puu.sh/3TAFi.png

Categories

Resources