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

7 Answers 7

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.

5
  • 5
    This is a serious bug. Do the developers know about this issue?? Jun 7, 2015 at 15:53
  • yes, this works, kill android studio, unplug usb, reload android studio, replug usb Jun 25, 2015 at 9:28
  • 3
    @user3290180, No need to Close Android Studio just replug USB cable. It's enough.
    – Hesam
    Jun 25, 2015 at 10:19
  • Works on Windows Android Studio 1.3
    – Nathan
    Aug 5, 2015 at 5:36
  • Fixes it on Linux VM as well, nice Nov 29, 2016 at 14:54
25

Open your terminal and reset adb:

adb kill-server
adb start-server
3
  • 1
    Awesome! I tried updating Android Studio, no success, but this little trick worked :)
    – AVEbrahimi
    Jul 29, 2015 at 11:46
  • 3
    I also crt alt deleted adb.exe that also seems to work Oct 29, 2015 at 7:07
  • killing adb unfroze AS but starting adb and trying to run my app did freeze it again. I had to restart the AVD, too.
    – Giszmo
    Jul 6, 2017 at 17:27
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
2
  • 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, 2015 at 7:01
  • No problems are reported. I started using installDebug instead of building in the IDE.
    – nurettin
    Jun 19, 2016 at 16:40
2

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.

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.

4
  • 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, 2015 at 12:55
  • @Virmundi This didn't work for me either. Could you post what you changed in the XML to fix this problem? Mar 28, 2015 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, 2015 at 1: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.
    – nww04
    Dec 22, 2015 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.)

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.