Android Studio Manifest Missing Error In Gradle

2019-01-14 02:11发布

问题:

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.

回答1:

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.



回答2:

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]



回答3:

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.



回答4:

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