Error running android: Gradle project sync failed. Please fix your project and try again

前端 未结 30 2972
南方客
南方客 2020-11-30 18:32

Android Studio (1.2 RC0) keeps telling me Error running android: Gradle project sync failed. Please fix your project and try again. How can I find out what th

相关标签:
30条回答
  • 2020-11-30 18:54

    I had the exact same error message

    Error running android: Gradle project sync failed. Please fix your project and try again

    , but if none of the above fixes your error, then I would highly suggest for you to check your syntax inside the AndroidManifest.xml file.

    That fixed if for me. I don't understand why the error-message is so misleading, since it had nothing to do with the build gradle directly.

    Please also see this SO-answer here, which has lead many of us in the right direction.

    0 讨论(0)
  • 2020-11-30 18:55

    I encountered this in a unique situation: had refactored the word "time" to "distance" for one of my variables. And when I did the refactor, accidentally had it change the name of one of my gradle dependencies / implementations.

    This is a rare cause of the error, but a possibility. So make sure all your dependencies are properly implemented in build.gradle

    0 讨论(0)
  • 2020-11-30 18:56
    1. Goto File -> Invalidate caches / Restart
    2. Shutdown Android Studio
    3. Rename/remove .gradle folder in the user home directory
    4. Restart Android Studio (It will download gradle metadata and data)
    5. Gradle build succeed
    6. Rebuild project. Done.
    0 讨论(0)
  • 2020-11-30 18:56

    It was yelling at me about a line in my xml file (which was perfectly valid and never had problems the entire time I've worked on the project). I deleted the line and even after running again and cleaning and rebuilding it kept yelling at me about the completely blank line. I restarted android studio and removed the .gradle folder and it finally worked. Hopefully someone in my shoes that had all of the other answers in this thread fail them will see this answer and save a few hours.

    I had this problem (clicked a prompt to "sync with gradle" on my perfectly valid and working project and it killed everything) and I researched for hours trying to figure out how to fix this, including this thread among many others. I finally found my solution, so hopefully, it'll help somebody (and hopefully they fix this terrible system)

    0 讨论(0)
  • 2020-11-30 18:57

    This could be due to Android Studio version conflict of v3 and v4 especially when you import a project in android stdio v4 which was previously built in v3.

    Here are the few things you need to do:

    • remove the .gradle and .idea folders from the main Application folder.
    • import the project in the android studio.
    • after the sync finished, it will ask you to update the android studio supported version.
    • click update.
    • done.
    0 讨论(0)
  • 2020-11-30 18:58

    it looks different from one situation to another. for me i did an installation and update a lot of things that the sdk manager said to then i had this problem. all i did was: from file -> Invalidate caches/Restart (a dialog will pop-up) choose Invalidate and restart.

    after the restart is done. everything was fixed but i needed to create a new emulator and delete the old one. (android studio 1.3.1) (one professional must edit this to be more understandable) . . . Here everything was fine, but your machines also needs restart because some system files are changed, to sync them we have to restart the system.

    0 讨论(0)
提交回复
热议问题