42

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:

  1. Open an existing Android Studio Project

  2. Import Project (Eclipse ADT, Gradle, etc.)

test

MBH
  • 16,271
  • 19
  • 99
  • 149
  • Same configuration on my system, didn't get such issue yet. did you retried. – lRadha Oct 01 '16 at 06:58
  • 2
    of course for many times, Android studio then totally stuck and i needed to kill it from the task manager. @lRadha – MBH Oct 01 '16 at 07:00
  • The problem is probably with the gradle distribution download or dependencies resolve. Check if any network proxy is set on your os or IDE – Farhad Oct 01 '16 at 07:00
  • i dont have any problem with the network, i made sure that internet connection is working and there is not proxy @FarhadFaghihi – MBH Oct 01 '16 at 07:01
  • is that an Android studio code or Eclipse – lRadha Oct 01 '16 at 07:03
  • android studio code with gradle in it. @lRadha – MBH Oct 01 '16 at 07:06
  • then import it as android project, the first option. (And also make sure that all the applications burning CPU must be closed first.) If it did not work just remove the gradle files and import it as Eclipse, ADT project – lRadha Oct 01 '16 at 07:17
  • @lRadha i wrote in the question that i have tried both options and same result – MBH Oct 01 '16 at 07:18
  • 1
    just remove gradle files from the project folder and try again – lRadha Oct 01 '16 at 07:19
  • @lRadha Yes that was it ! i removed the gradle, i copy and pasted it from another project, it worked now ! Thank you – MBH Oct 01 '16 at 07:29
  • @lRadha please add it as answer to accept it – MBH Oct 01 '16 at 08:42

12 Answers12

32

There is downloading of Gradle going on at the background. Just wait for it to finish.

Ciado
  • 1,996
  • 2
  • 17
  • 15
21

Just Remove Gradle files from your project folder and retry.

Hope this will help.

lRadha
  • 641
  • 6
  • 16
  • 2
    it worked ... i deleted all gradle folder and copied it from another project and pasted it, this worked for me – MBH Oct 01 '16 at 10:39
  • 1
    @MBH yes, as you said I just replaced that 'gradle' folder with one of a project I worked on recently. – CodeToLife Apr 29 '17 at 16:00
4

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.

3

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.

  • 1
    the first option which worked for me, i already use Android studio 2.2 which is **STABLE version** .. thank you – MBH Oct 01 '16 at 10:39
2

I had deleted all gradle folder and copied it from another project and pasted it, this worked for me

MBH
  • 16,271
  • 19
  • 99
  • 149
2

Try to remove C:\Users\User.gradle

Oguzhan Cevik
  • 638
  • 8
  • 18
  • Thanks! This works for me. The actual path is c:\users\[username]\.gradle I ran a couplel of react-native projects before – Dat TT Sep 13 '17 at 01:13
2

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.

  1. 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)
  2. 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++.

M. Usman Khan
  • 3,689
  • 1
  • 59
  • 69
1

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!!!

Manuj
  • 11
  • 1
1

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

K.A. Siddiqui
  • 49
  • 1
  • 8
1

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).

Vivek Thakkar
  • 131
  • 3
  • 11
0

Deleting temp and temp% worked for me!

0

Download manually gradle-3.3-all.zip

and extract into /Users/[yourUsername]/.gradle/wrapper/dists/gradle-3.3-all/55gk2rcmfc6p2dg9u9ohc3hw9/

hitman47
  • 237
  • 2
  • 14