Ninad Desai
Ninad Desai

Reputation: 567

Android Studio hangs / Freezes when project build fails

I am experiencing a very wired problem since this evening.

If I have any errors in my android project, and build is failed, then my Android studio gets frozen / stuck. I cant do anything but kill the Android studio application. Even if I open the same project next time, gradle will try to build and freezes again. [Please find attached screen shot]

Only solution I could find is .... I have to find what exactly cause the "build fail" and I will have to resolve the issue using some other editor, and then my android studio will start working.

Thing is it was working without any issues till this evening; and suddenly broken down. Any one else having the same issue ??

-n

enter image description here

Upvotes: 34

Views: 31752

Answers (7)

buxik
buxik

Reputation: 2625

Open your terminal and reset adb:

adb kill-server
adb start-server

Upvotes: 25

GilbertLee
GilbertLee

Reputation: 696

@Hesam's answer doesn't work for me. Using OSX and AS 1.2.1.1, my building stuck in 'Scanning files to index' and I cannot solve it even after restarted my Macbook. Below work for me:

  1. Shut down Android Studio (force to kill or just unplug the usb you will be good to go)
  2. Go to the directory of AndroidStudioProjects and move the application directory out to some other location (outside AndroidStudioProjects).
  3. Restart the android studio, now you will be shown the screen asking you whether you want to start a new project or open an old one.
  4. Again paste the folder you have cut and kept aside in step 2 back to AndroidStudioProjects directory.
  5. In the android studio prompt, select open existing project and select the directory you have now just pasted to AndroidStudioProjects.

It should work for my case.

Upvotes: 0

Hesam
Hesam

Reputation: 53600

If you are using Android Studio v1.2.1.1 or newer and you are using Macbook, I've recently seen that if your device is connected to your laptop (by usb have no idea about over the wifi) and you sleep your laptop then login again, Android Studio hang. Therefore, you need to unplug usb cable then you should see Android studio is happy and then reconnect your usb cable.

Upvotes: 55

Morris
Morris

Reputation: 613

Based on barbarian's answer I did this on my Mac:

start a terminal
chmod +x gradlew
./gradlew
./gradlew build

This last step showed an error in my xml file, indicating that I used unescaped single quotes. Fixing that solved the hangup.

Upvotes: 2

barbarian
barbarian

Reputation: 101

This is how I solved the same problem:

  • Go to your project directory using your terminal
  • run ./gradlew (or gradlew.bat) assembleDebug
  • Fix the problems reported by gradle
  • Restart android studio and the problem is gone

Upvotes: 10

scrrr
scrrr

Reputation: 5340

In my case the same thing happened, after I had added image-resources with dashes in the filename.

I manually deleted them, renamed them, and added them with underscores in the name, and Android Studio worked normally again.

(I am not sure the dashes were the reason, why should they, but doing the above fixed it.)

Upvotes: 1

Ninad Desai
Ninad Desai

Reputation: 567

Well, I uninstalled android studio and installed it again, and now the problem has gone away. I still wonder how in the world it broke in the first place.

In case some one else is facing the same issue, try reinstalling your studio. In case if you are using Mac osx refer How to completely uninstall Android Studio? to uninstall Android studio properly; Because only deleting App will not completely uninstall it.

Upvotes: 1

Related Questions