12

The new app publishing format, the Android App Bundle, is an improved way to package your app. The Android App Bundle lets you more easily deliver a great experience in a smaller app size, allowing for the huge variety of Android devices available today. You don’t need to refactor your code to start benefiting from a smaller app.

I'm getting this error trying to build my app Android Bundle:

File 'root/AndroidManifest.xml' uses reserved file or directory name 'AndroidManifest.xml'.

APK generation works fine.

This is my project file structure:

enter image description here

And this is my AndroidManifest.xml, located under {ProjectName}/app/src/main:

<?xml version="1.0" encoding="utf-8"?>
            <manifest xmlns:android="http://schemas.android.com/apk/res/android"
                xmlns:tools="http://schemas.android.com/tools"
                package="com.XXXX.XXXX"
                android:installLocation="auto">

                <uses-permission android:name="android.permission.INTERNET" />
                <uses-permission android:name="android.permission.WAKE_LOCK" />
                <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>

                <!-- These permissions are strongly recommended and will result in higher performance -->
                <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
                <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
                <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
                <uses-permission android:name="android.permission.VIBRATE" />

                <application
                    android:name="com.app.webview.Application"
                    android:allowBackup="true"
                    android:icon="@mipmap/ic_launcher"
                    android:label="@string/app_name"
                    android:supportsRtl="true"
                    android:theme="@style/AppTheme"
                    android:hardwareAccelerated="true">
                    <activity
                        android:name="com.app.webview.MainActivity"
                        android:configChanges="keyboardHidden|orientation|screenSize"
                        android:label="@string/app_name"
                        android:launchMode="singleTask">
                        <intent-filter>
                            <action android:name="android.intent.action.MAIN" />

                            <category android:name="android.intent.category.LAUNCHER" />
                        </intent-filter>

                        <!-- Universal APP Link -->
                        <intent-filter>
                            <action android:name="android.intent.action.VIEW" />

                            <category android:name="android.intent.category.DEFAULT" />
                            <category android:name="android.intent.category.BROWSABLE" />

                            <data android:scheme="http" />
                            <data android:scheme="https" />
                            <data android:host="@string/app_host" />
                        </intent-filter>
                    </activity>

                    <!-- Push -->
                    <!-- Services that handles incoming message -->
                    <service
                        android:name="com.app.webview.Providers.FCM.FcmListenerService">
                        <intent-filter>
                            <action android:name="com.google.firebase.MESSAGING_EVENT" />
                        </intent-filter>
                    </service>

                    <!-- Called if InstanceID token is updated -->
                    <!-- This may occur if the security of the previous token had been compromised -->
                    <service
                        android:name="com.app.webview.Providers.FCM.FcmInstanceIDListenerService"
                        android:exported="true">
                        <intent-filter>
                            <action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
                        </intent-filter>
                    </service>

                    <!-- Facebook Config -->
                    <meta-data
                        android:name="com.facebook.sdk.ApplicationId"
                        android:value="@string/id_facebook" />

                    <activity
                        android:name="com.facebook.FacebookActivity"
                        android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
                        android:label="@string/app_name"
                        android:theme="@android:style/Theme.Translucent.NoTitleBar"
                        tools:replace="android:theme" />

                    <provider
                        android:name="com.facebook.FacebookContentProvider"
                        android:authorities="@string/facebook_provider"
                        android:exported="true"
                        tools:replace="android:authorities" />

                    <!-- Fabric -->
                    <meta-data
                        android:name="io.fabric.ApiKey"
                        android:value="XXXX" />
                </application>  
            </manifest>
13
  • If that's your actual manifest, why is it under a sub-directory? Sep 25, 2018 at 14:35
  • It's located under modulefolder/src/main/AndroidManifest.xml Sep 25, 2018 at 14:37
  • How are you adding this module? Are you just copying the folder into your current source? Sep 25, 2018 at 14:41
  • 1
    No, I'm waiting for a fix from Google side and using APK Oct 4, 2018 at 6:11
  • 1
    Same problem here. APK is building OK but not Bundle.
    – men
    Dec 1, 2019 at 13:49

7 Answers 7

10

A much simpler fix until Facebook fixes the SDK would be to add this to the packagingOptions in the android { } block of your app's build.gradle:

android {
   packagingOptions {
      exclude 'AndroidManifest.xml' //This fixes a bug in FAN 5.0.1
   }
}

I can only confirm this works when building an App Bundle, I do not know about a regular APK.

4
  • 1
    Brilliant, I had tons of dependencies, and I had no idea what was blocking me building the App Bundle because of this AndroidManifest.xml error. I spent hours investigating, downgrading dependencies, etc. Finally I added this, and now I can build the App Bundle (this is a quick fix only, but still works). Thanks!! Nov 21, 2018 at 12:41
  • Facebook has since updated the SDK to resolve this bug, you should update to 5.1.0 or later. Mar 15, 2019 at 14:23
  • 1
    You are an angel, this code worked like a charm. Thank you!! Aug 26, 2019 at 10:38
  • Would this not exclude AndroidManifest.xml from your final bundle and thus make the apks unusable on a device? Jun 2 at 17:53
8

In my case, my error was caused by

com.facebook.android:audience-network-sdk

I only downgrade audience-network-sdk from 5.0.0 to 4.99.3 and everything starting to work fine. I hope this help you.

Updated: As Sebastian said, now you can update audience-network-sdk from 5.0.0 to 5.1.0.

0
6

Since October 31, Facebook released version 5.1 of the Audience Network SDK. Using

implementation 'com.facebook.android:audience-network-sdk:5.1.0'

fixed the issue for me.

1

If I'm reading the file tree right, you have your AndroidManifest.xml file in the res folder, which migth be the reason why you're seeing the error. Try to put the file in {ProjectName}/app/src/main and rebuild the project.

4
  • It isn't there, in the file tree looks like it's inside but is under {ProjectName}/app/src/main Sep 25, 2018 at 14:57
  • 1
    IntelliJ's tree view is weird. The expand arrows are actually aligned with the parent folder. Sep 25, 2018 at 14:58
  • If that's the case, can you share what's in your manifest file? There might be an error there.
    – Noterezeck
    Sep 25, 2018 at 15:00
  • The mainfest file looks good. No wrong/ly placed tags or anything like that. Have you tried resyncing the project with File System? Shortcut for that in Android Studio is Ctrl + Alt + Y
    – Noterezeck
    Sep 26, 2018 at 6:11
0

I ran into the same bug. Had to change a few things before getting a working build. For me it was:

  1. downgrade facebook audience-network-sdk from 5.0.0 to 4.28.2
  2. downgrade okio from 2.1.0 to 2.0.0
  3. update proguard config for okio, okhttp & retrofit
  4. not using R8

I hope this helps you.

0

Late to answer but I was facing the same issue with slightly different scenario. I was not using the above mentioned facebook library but it was some other library, which I could not figure out because of less info by the build.

I had one sub module (say module1) which was including another library, which further had many dependencies. So I put,

packagingOptions {
        exclude 'AndroidManifest.xml'
}

In the build.gradle of module1 and then the issue was resolved.

Just writing this answer to convey putting in app's build.gradle might not solve issue for all the cases.

Thanks a lot @Jason for showing the right direction.

0

To those who what to know why facebook library has such issue:

You can download the aar file from maven respository, then drag it into Android Studio and expand the classes.jar. You would see there is a manifest file inside the classes.jar.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.