• 3

A PHP Error was encountered

Severity: Notice

Message: Undefined index: userid

Filename: views/question.php

Line Number: 191


File: /home/prodcxja/public_html/questions/application/views/question.php
Line: 191
Function: _error_handler

File: /home/prodcxja/public_html/questions/application/controllers/Questions.php
Line: 433
Function: view

File: /home/prodcxja/public_html/questions/index.php
Line: 315
Function: require_once

name Punditsdkoslkdosdkoskdo

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


enter image description here

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.

  • 55
Reply Report

Open your terminal and reset adb:

adb kill-server
adb start-server
  • 25
Reply Report

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
  • 10
Reply Report
      • 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.

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

start a terminal
chmod +x 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.

  • 3
Reply Report

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.

  • 1
Reply Report
    • 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.
      • 1
    • @Virmundi This didn't work for me either. Could you post what you changed in the XML to fix this problem?
      • 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.
      • 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.

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

  • 1
Reply Report

@Hesam's answer doesn't work for me. Using OSX and AS, 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.

  • 0
Reply Report