16

I am new to Android Studio and I have just created a new project with only one Activity with fragments(Android studio created that), and when I ran the MyActivity.java , error occurs:

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

Nothing more in my event log.

I have no idea why it is, and This link did not helps.

One clue is that Gradle project sync in progress is flowing all the time , just after I restart the Studio.

6
  • can you post your log ... and which version of studio you are using? Commented Jul 16, 2014 at 11:07
  • I have the same problem, did you solve the problem? Commented Aug 4, 2014 at 19:22
  • stackoverflow.com/a/21168562/1442541 Commented Sep 21, 2014 at 7:28
  • 1
    You can find a answer here: stackoverflow.com/questions/21066598/… Commented Jun 16, 2015 at 12:07
  • 1
    You should not run MainActivity . you should run app that contains MainActivity. Commented Nov 14, 2015 at 2:48

2 Answers 2

8
  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
  7. Done
Sign up to request clarification or add additional context in comments.

Comments

0

The exact same error message also pops up if there is a syntax-error inside your AndroidManifest.xml file. So if the above won't work - which it didn't for me - then check the AndroidManifest.xml syntax. That will save you thousands of frustrating hours.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.