Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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'
like image 912
AbreQueVoy Avatar asked Jun 27 '14 20:06

AbreQueVoy


People also ask

What is AndroidManifest XML in Android Studio?

Every app project must have an AndroidManifest. xml file (with precisely that name) at the root of the project source set. The manifest file describes essential information about your app to the Android build tools, the Android operating system, and Google Play.

Where is the AndroidManifest XML file in Android Studio?

Every project in Android includes a Manifest XML file, which is AndroidManifest. xml, located in the root directory of its project hierarchy. The manifest file is an important part of our app because it defines the structure and metadata of our application, its components, and its requirements.

What is AndroidManifest XML explain its use in Android app development?

The Android manifest file helps to declare the permissions that an app must have to access data from other apps. The Android manifest file also specifies the app's package name that helps the Android SDK while building the app.

What is AndroidManifest XML and what should we include in it?

The AndroidManifest. xml file contains information of your package, including components of the application such as activities, services, broadcast receivers, content providers etc.


1 Answers

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.

like image 118
Eugen Martynov Avatar answered Nov 14 '22 21:11

Eugen Martynov