How does the Android Studio gradle plugin manage resource files (AndroidManifest.xml)?

I have a build.gradle project located in the myApp/app/ directory. AndroidManifest.xml is located in the myApp/app/src/main directory at the same level as the java/ and res/ directories.

When synchronizing a project, I get a notification about a missing manifest file. No wonder, in fact, when the path is really wrong. The source file is installed as:

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

and an error notification reports:

Error:Cause: java.io.FileNotFoundException: /home/aqv/AndroidStudioProjects/myApp/src/main/AndroidManifest.xml (No such file or directory)

When I change the source to:

 sourceSets { main { manifest.srcFile 'main/AndroidManifest.xml' } } 

the text changes to:

Error:Cause: java.io.FileNotFoundException: /home/aqv/AndroidStudioProjects/myApp/app/main/AndroidManifest.xml (No such file or directory)

As you can see, the path fragment is missing: myApp/app/src/ (when setting the src/main/AndroidManifest.xml path, the error says to search for the manifest file in myApp/src/main , so it truncates the app/ directory).

Is this some kind of gradle error or is my project not configured correctly?

In search of a solution, I found one thread in SO, but the solution from there did not work in my case. I have dependencies installed as:

 compile 'com.android.support:support-v4:19.1.0' compile 'com.android.support:appcompat-v7:19.1.0' 
+7
android android-studio android-manifest gradle
source share
1 answer

Writing an answer as it can also be a problem for someone.

By default, Android Studio creates a project with several modules. So you have build.gradle in the root folder of your project and another build.gradle in the application folder:

 <your project name> /app /src build.gradle build.gradle settings.gradle 

The parent build.gradle usually edited if you want to specify default settings for all subprojects. It looks strange, because at the moment you have only one subproject.

The starter problem was that he added / changed root build.gradle instead of the build.gradle application .

+8
source share

All Articles