AbreQueVoy
AbreQueVoy

Reputation: 2316

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

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

When synchronizing the project, I receive notification about missing manifest file. No wonder, actually, when the path is really incorrect. Source file is set as:

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

and the error notification says:

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, there is missing path fragment: myApp/app/src/ (when setting src/main/AndroidManifest.xml path, the error says about looking for manifest file in myApp/src/main, so it ommits the app/ directory).

Is it a kind of gradle's bug or my project is misconfigured?

Looking for solution I found one thread at SO, but the solution from there didn't work in my case. I have dependencies set as:

compile 'com.android.support:support-v4:19.1.0'
compile 'com.android.support:appcompat-v7:19.1.0'

Upvotes: 7

Views: 6622

Answers (1)

Eugen Martynov
Eugen Martynov

Reputation: 20140

Writing an answer since could be also issue for someone.

By default Android Studio creates multi module project. So you have build.gradle in the root folder of your project and another build.gradle in app folder:

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

The parent build.gradle is usually edited if you want to specify default settings for all subprojects. It looks odd since you have only one subproject for now.

The topic starter issue was that he was adding/modifying root build.gradle instead of app folder build.gradle.

Upvotes: 8

Related Questions