Android Studio hangs / Freezes when project build fails

后端 未结 7 481
闹比i
闹比i 2021-02-05 01:38

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

相关标签:
7条回答
  • 2021-02-05 02:01

    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.

    0 讨论(0)
  • 2021-02-05 02:01

    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.

    0 讨论(0)
  • 2021-02-05 02:08

    Open your terminal and reset adb:

    adb kill-server
    adb start-server
    
    0 讨论(0)
  • 2021-02-05 02:08

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

    0 讨论(0)
  • 2021-02-05 02:21

    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 讨论(0)
  • 2021-02-05 02:24

    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
    0 讨论(0)
提交回复
热议问题