13

The issue I've had over the past few months is that Android Studio would often get stuck on Gradle: build, as seen here. Android Studio itself would stay responsive but the build simply wouldn't progress. It also never generates any kind of error, so I can't really post any useful information. Once in a blue moon it might suddenly work, but nothing reliable.

Recently I found a post here on Stack Overflow where someone's Android Studio would get stuck on Gradle: build when he tried to create a new project, and he noticed that this issue didn't exist in the 32-bit version of Android. So I thought, why not try that. Turns out that building isn't an issue anymore, but assembleDebug is, when trying to build the application. As can be seen here.

Of course all these commands work flawlessly when run using command prompt and gradlew.

What I've tried so far:

  • Reinstalling Android Studio (including the removal of .AndroidStudioProject)
  • Upgrading Android Studio to the latest version
  • Removing any build files from projects
  • Creating completely new projects in Android Studio
  • Switching from 64-bit to 32-bit Android Studio

I'm running the latest version of Android Studio, using version 19.1.0 of the build tools, gradle v0.11+ and am on Windows 8.1.

Is there anything else I can try? This is starting to become seriously annoying. The last possible solution I can come up with is just doing a complete format and a fresh Windows installation.

fdorssers
  • 719
  • 2
  • 8
  • 19
  • 1
    reinstall android-studio? – someguy234 Aug 12 '14 at 18:57
  • 2
    @gurinderhans Thank you for the suggestion, but that is actually the first item in the list and unfortunately that didn't help at that point in time. However a few weeks later everything started working fine again and I really can't remember doing anything specific to get it working again. – fdorssers Aug 12 '14 at 20:20
  • 1
    I didnt notice this question is pretty old (Sorry!) but glad everything works. Maybe it got fixed because of an update? Anyways i'm glad everything's fine – someguy234 Aug 12 '14 at 20:31
  • 1
    Is there any chance you were using an Android device to USB tether? That caused this same issue for me. As soon as I disable USB tethering, the first build runs quickly. Then I can reenable USB tethering. – Tim Cooke Jan 13 '15 at 16:40
  • @SQLiteNoob I made my comment an answer in the hopes that it will help for someone else. – Tim Cooke May 21 '15 at 00:10
  • http://stackoverflow.com/a/37378848/538284 – Omid Raha May 22 '16 at 19:53

7 Answers7

13

I was experiencing the same problem, and the solution was very unexpected in my case: AVAST antivirus was somehow interfering with the Gradle:build process. Deactivating this antivirus solved the problem!

5

Because there is no answer to this problem I will share, what I have done, to solve this issue. From what I have seen, the problem is that there is a dependancy(or many) from a maven repo that can not be loaded. So you have to take all dependacy one by one and check if exist on the maven repo.

For example I was having a dependancy for "org.jraf:android-switch-backport:1.3.1" from "http://JRAF.org/static/maven/2" that at that time could not be opened.

My build.gradle looked like this:

  repositories {
      mavenCentral()
      maven {
        url "http://JRAF.org/static/maven/2"
      }
  }

  compile "org.jraf:android-switch-backport:1.3.1
elvisrusu
  • 378
  • 5
  • 18
  • 1
    I'd say in general, even if repos exist, if there are network problems the problem may happen. I tried lots of stuff until I read this answer and realized that my wifi connection was dead. Refreshed it and boom! a couple of dependencies were updated. It's amazing on none of the consoles there is a message about that. – rupps Jun 03 '17 at 20:11
3

For me, this problem occurred when I was USB tethering using an Android device. The first build took anywhere from 5-10 minutes, and every subsequent build took about 3-7 seconds. I found that by disabling USB tethering, the first build completed quickly (and so would all subsequent builds). After the first build completed, I could reenable USB tethering.

Tim Cooke
  • 862
  • 7
  • 14
2

If you have a fresh Ubuntu 14.04 with Android Studio 1.5, you may be missing a library. Try this:

sudo apt-get install lib32z1

Another stack overflow answer

Community
  • 1
  • 1
Yvan Pearson
  • 319
  • 4
  • 6
0

It happens 1 in 2 times for me. The hack that works for me is File->Exit and confirm exiting. Then a message shows up telling me that Gradle is running and then all of a sudden the screen to choose the device shows up. I Click NO and all goes well again.

Anyway, still a bummer, but I have not found an answer yet.

aldux
  • 2,774
  • 2
  • 25
  • 36
0

My problem was that the Android Sdk executables were missing the executable bit. You can check some of your binaries like /Sdk/build-tools//aapt to see if they have permission to execute. If not you can solve it by running this on the Sdk folder

chmod -R +x ./
ibrabeicker
  • 1,786
  • 2
  • 19
  • 31
0

If you are behind a proxy on ubunthu you might need to set your gradle system wide proxy:

sudo nano ~/.gradle/gradle.properties 

And enter the following entries:

systemProp.http.proxyHost=<Your Host>
systemProp.http.proxyPort=<Your Host Port>