34

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

Ninad Desai
  • 558
  • 1
  • 7
  • 10

7 Answers7

55

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.

Hesam
  • 52,260
  • 74
  • 224
  • 365
25

Open your terminal and reset adb:

adb kill-server
adb start-server
buxik
  • 2,583
  • 24
  • 31
10

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
barbarian
  • 101
  • 1
  • 3
  • This worked for me when a project hanged on startup. It was downloading a new gradle version, but the UI didnt give any indication. – DagW Oct 15 '15 at 07:01
  • No problems are reported. I started using installDebug instead of building in the IDE. – nurettin Jun 19 '16 at 16:40
3

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.

Morris
  • 593
  • 7
  • 7
1

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.

Community
  • 1
  • 1
Ninad Desai
  • 558
  • 1
  • 7
  • 10
  • I tried the linked article. It didn't work. I found the error my XML that caused the failure. Fixing that got it to work. But there is still something fundamentally flawed in Android Studio. – Virmundi Mar 19 '15 at 12:55
  • @Virmundi This didn't work for me either. Could you post what you changed in the XML to fix this problem? – Aravindan R Mar 28 '15 at 20:17
  • 1
    @AravinR, the error was due to having two elements with same ids. It is a local issue for me. The best I could do was NOT build until I looked at the last error in the old build log. From there I had to hunt to the XML issue. – Virmundi Mar 29 '15 at 01:28
  • 1
    Sigh, node.js and the likes, especially this Android Studio are such of malware of sorts. Look at the instruction on how to uninstall them. Such a hassle. As a developer, whose time is very CRUCIAL, doing the steps suggested is such a chore to do. This unbelievable in biblical proportions. – Neon Warge Dec 22 '15 at 13:03
1

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

scrrr
  • 5,135
  • 7
  • 42
  • 52
0

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

GilbertLee
  • 654
  • 1
  • 6
  • 21