I want to run my unit test with this command
gradlew.bat connectedInstrumentTest
But it tries to download https://services.gradle.org/distributions/gradle-2.2.1-all.zip
And my corporal network blocks it. Hence, I want to setup the zip manually, I already downloaded it from browser.
The ways I failed are listed below
Pasting it in Program Files\Android\Android Studio\gradle\
gradle-2.2.1 didn't work
File -> Settings -> Build execution, Deployment -> Build Tools and
defining the gradle home directory didn't work
Any suggestions except these will be much appreciated. Thanks.
Solution :
1). Delete the C:\Users\username\.gradle folder
2). Download http://downloads.gradle.org/distributions/gradle-2.2.1-all.zip
3). Create a new project in android studio.
4). When this time it stucks at gradle building, Force close the android studio.
5) Now go to C:\Users\username\.gradle\wrapper\dists\gradle-2.2.1-all\c64ydeuardnfqctvr1gm30w53 (the end directory name may be different)
6) Delete gradle-2.2.1-all.zip.lck and other files from this directory.
7) Paste the new downloaded gradle-2.2.1-all.zip here.
8) Run the android studio. :)
In your command you're using the Gradle Wrapper. The Gradle wrapper is a thin wrapper around the real Gradle bin. It's intended to be checked in to your source control and it then downloads the version of Gradle you've defined in gradle/wrapper/gradle-wrapper.properties. The advantage here is the version of Gradle used in the build is directly tied to the source control.
You have 2 options:
use the gradle command instead of gradlew - this will use the gradle that's installed on the local machine (assumes that 'gradle' is on the PATH). The drawback here is you have to have installed Gradle somewhere before the build will work.
change distributionUrl in gradle/wrapper/gradle-wrapper.properties to point to a different URL and host that file yourself somewhere. You get all the advantages of the wrapper but fix the problems you're having downloading it.
Mostly, this error occurs due to brake in internet or slow connection network.
A gradle file downloads partially, this zip file isn't extractable and neither does re-download using Android Studio work.
So, to solve this problem, you have to:
Delete the gradle download folder or download the gradle zip file manually and configure using the following method
Download requires gradle and past the zip into C:\Users\your_pc_name\.gradle\wrapper\dists
Finally, open Android Studio and run the project.
The gradle version care fully before downloading
Related
I'm trying to follow the Kotlin Koans tutorial in Android Studio by installing the EduTools plugin and choosing Kotlin Koans course.
Everything works fine, but when I try "Check Task" in the Task Description panel, I get this error:
Failed to launch checking
I also tried the plugin with Intellij IDEA and got the same error.
Using:
Android Studio 3.2 with EduTools 2.0-2018.1-443
Intellij IDEA 2018.2.3 with EduTools 2.0-2018.2-906
Maybe could try IntelliJ Idea Edu which comes already bundled with EduTools.
I found the problem in IDE logs as #NullReference suggested.
INFO - ecker.gradle.GradleCommandLine - Failed to launch checking
Cannot run program "./gradlew" (...) No such file or directory
I had configured the project (Settings / Build, Execution, Deployment / Build Tools / Gradle) to use a local Gradle distribution and it seems that EduTools plugin always looks for the Gradle Wrapper, so I just had to generate a Wrapper for project and configure it to use my local Gradle distribution:
gradle wrapper --gradle-distribution-url file:///path/to/local/gradle-4.6-all.zip
In my case I had a problem related to JDK 11 and I had JDK 8 installed.
This is how I fixed the problem:
Go to Settings / Build, Execution, Deployment / Build Tools / Gradle.
At Gradle JVM select JDK 11 path.
It worked for me.
I also got this issue. Finally, I 've resolved it by configuring my gradle bin to PATH.
Here are series of commands to configure Gradle into you Path.
# cd ~
# touch .bash_profile
# open -e .bash_profile
//to edit your bash_profile ,you need to input your local path to bash_profile,like this:
export GRADLE_HOME=/Users/PCNAME/.gradle/wrapper/dists/gradle-4.5-bin/bgd6nrwgxy3inh8yed6gmsvbx/gradle-4.5/ --- use your own grade path to replace them.
export PATH=${PATH}:${GRADLE_HOME}/bin
# source .bash_profile
# gradle -v // you will see your gradle version if your configure successfully.
Restart Android Studio, try to run your EDUTOOLS.
I received the same error. I closed Android Studio and created a new Koans project thinking I must have done something wrong. This time I received a new build time error when trying to "Check". None of this made sense so I just shut down Android Studio, reopened the Koans project I just created and clicked "Check". Everything seemed to work now.
Had the same problem. Just Sharing how I fixed this problem.
I opened build.gradle of my Kotlin Koans Project and scrolled down to where wrapper was defined.
Pressed play icon right next to it.
Was greeted with an error
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)
Followed Answer by Hamid
To resolve this issue close Android Studio and delete the following
directory's content, necessary files will be downloaded on IDE's next
launch.
macOS: ~/.gradle/wrapper/dists
Linux: ~/.gradle/wrapper/dists
Windows: C:\Users\your-username.gradle\wrapper\dists
Restarted Android Studio and it worked like a charm.
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.
How do I export a project in ZIP format in Android Studio?
I have always worked with Eclipse that has this feature.
Starting with Android Studio 3.0, you can use File | Export to Zip File... to export your project. If you're using an older version, you can use the file manager of your operating system to pack the directory of your project into a .zip file.
In Android Studio 4.1 the export as ZIP option has been moved to File - > Manage IDE Settings - > Export to Zip file
If you want to export your project to a .zip you'll need to upgrade your version of Android Studio to version 3.0
right click on app folder
then send to
then compressed via zip
Go to File
Choose option Export to Zip File
Note:
This option is removed in Android Studio 4.1
You can first push the project to Github and then download the project as zip. Only the necessary code will be pushed to Github, hence making it easier for others to go through the code.
Steps to push to Github:
1. In the Project Window, select Android. Only the app folder and necessary code can be seen.
2. Click on VCS -> Import from Version Control -> Share Project on Github.
3. Enter project name and description.
4. Enter a commit message. You can select/deselect files to be pushed.
Note: You will have to setup Github first in Android Studio.
After this you will see a notification on top right of the IDE saying 'Project pushed to Github' and a hyperlink to the Github repository.
You can then download the repository as zip. This might seem to be a long process but it would help in the long run as your code can be easily managed using VCS within Android Studio itself.
File/ Manage IDE Settings/ Export to Zip File...
Choose the directory you want the file to be in
Wabam you got yourself a new zip file :D
note to future viewers: I am on Android Studio Version 4.1.1
Following worked for me, Android Studio 2.0, assuming there are no libs.
A. From the source project
1. Copy /app/build.gradle
2. Copy /app/src/* including subdirectories (only contains manifest, java and resources)
B. Create new project with the same package name, minSDK etc.
1. Replace /app/build.gradle
2. Replace /app/src/* including subdirectories
C. Synchronize
D. Clean Project
Windows:
First Open Command Window and set location of your android studio project folder like:
D:\MyApplication>
then type below command in it:
gradlew clean
then wait for complete clean process. after complete it now zip your project like below:
right click on your project folder
then select send to option
now select compressed via zip
It's easy, if you use git:
git archive -o latest.zip HEAD
Setup Git if you haven't already in Android Studio. Its free. From the terminal provided in the Android Studio go to a new fresh directory. Run this command: git clone <app directory path>
This will copy all the required file to load the project and also the commit history to the current new directory.
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.