28

I'm trying to figure out what I've done to my project. I recently added ActionBarSherlock to my project under the main project/library/ActionBarSherlock. When I did that something happened to my manifest file path because now the project cannot find it and I'm getting this error on Debug.

Gradle:

FAILURE: Build failed with an exception.

  • What went wrong: A problem occurred configuring root project 'ToDoListProject'.

    Failed to notify project evaluation listener. Main Manifest missing from C:\Users\Chris Johnson\AndroidStudioProjects\ToDoListProject\src\main\AndroidManifest.xml

  • Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

The reason it can't find the manifest is because it's located in the file

C:\Users\Chris Johnson\AndroidStudioProjects\ToDoListProject\ToDoList\src\main\AndroidManifest.xml

How do I set it to the correct location again?

Thanks.

Bobbake4
  • 24,509
  • 9
  • 59
  • 94
chris84948
  • 3,940
  • 3
  • 22
  • 25

4 Answers4

54

In the android section of your build.gradle file, you can try adding sourceSets with the manifest.srcFile variable.

android {
  sourceSets {
      main {
          manifest.srcFile 'ToDoList/src/main/AndroidManifest.xml'
      }
  }
}

That path may need to be adjusted slightly.

Kevin Crain
  • 1,905
  • 1
  • 19
  • 28
ootinii
  • 1,795
  • 20
  • 15
  • Any idea what would've caused this in the first place? Either way I'll try this later on tonight, thanks. – chris84948 Jun 13 '13 at 22:50
  • It's hard to say what could cause this, since Android Studio is basically in alpha, a lot changes with each subsequent update, so these issues are hard to track down sometimes. – ootinii Jun 14 '13 at 18:58
  • Originally had two "Gradle R package not found" and this error about AndroidManifest. I applied that to build.gradle and adjuste the path to mine. Now I have 50 "Gradle R package not found" instead of just two and I have only ONE project. – Lord of Scripts Jul 17 '13 at 20:51
  • 4
    Why would anybody put their AndroidManifest.xml in /src/main? This is not how traditional Android project guidelines recommend structuring a project. This deviates from the norm. – IgorGanapolsky Oct 08 '13 at 03:41
  • 4
    Hence the phrase "That path may need to be adjusted slightly." As far as I recall, that's where Android Studio generates the manifest for a gradle project. – ootinii Oct 08 '13 at 14:39
  • 2
    @IgorGanapolsky build flavours. – ataulm Nov 03 '13 at 14:14
  • I also found out that if you give the same string as the project name and module name in Android Studio, this confuses gradle. I had a structure (of gradle modules) `MyModule/Mymodule` It tried to look for the sources in the outer one, but they were created in the inner – varesa Jan 14 '14 at 13:45
  • 1
    @Igor: it does not seem to 'deviate from the norm': http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Project-Structure – MacD Jul 21 '14 at 11:14
  • I stand corrected. With the new Gradle build system, all projects are structured this way by default in Android Studio. – IgorGanapolsky Jul 21 '14 at 13:21
5

You can do it from here open module settings -> Select modules tab -> click on your module -> from structure tab on the right change path for manifest file

you can find your manifest file inside [module name]/src/[sub directory]

Amr Tealeb
  • 76
  • 1
  • 3
  • 6
    For those of us who aren't familiar with android studio or android apps in general, where is this "open module settings"? – The Muffin Man Jun 06 '17 at 16:10
1

I solved it by doing a clean via menu Build -> Clean project and a rebuild via menu Build -> Rebuild project

RoadXY
  • 447
  • 4
  • 10
0

Perhaps not exactly for this question, however I have the same error message, and it was due to gradle project not configured (this happened after pull from git), I selected "accept theirs" for all conflicts. local.properties was missing. So the team has removed files, "breaking" the project after the update. I readded local.properties, then i was able to reset gradle to use the gradle wrapper. Now it will recognize the android project including the manifest.

Nick
  • 2,735
  • 1
  • 29
  • 36