[英]Android App Bundle build error: reserved file
The new app publishing format, the Android App Bundle, is an improved way to package your app.新的应用程序发布格式 Android App Bundle 是对 package 应用程序的改进方式。 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.
Android App Bundle 让您可以更轻松地以更小的应用程序提供出色的体验,从而支持当今可用的各种 Android 设备。 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:我在尝试构建我的应用程序 Android 捆绑包时遇到此错误:
File 'root/AndroidManifest.xml' uses reserved file or directory name 'AndroidManifest.xml'.
文件“root/AndroidManifest.xml”使用保留文件或目录名称“AndroidManifest.xml”。
APK generation works fine . APK 生成工作正常。
This is my project file structure:这是我的项目文件结构:
And this is my AndroidManifest.xml, located under {ProjectName}/app/src/main
:这是我的 AndroidManifest.xml,位于
{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>
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:在 Facebook 修复 SDK 之前,一个更简单的修复方法是将其添加到应用 build.gradle 的 android { } 块中的 PackagingOptions:
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.我只能在构建 App Bundle 时确认这有效,我不知道常规 APK。
In my case, my error was caused by就我而言,我的错误是由
com.facebook.android:audience-network-sdk
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.我只将 Audience-network-sdk 从 5.0.0 降级到 4.99.3,一切都开始正常工作。 I hope this help you.
我希望这对你有帮助。
Updated: As Sebastian said, now you can update audience-network-sdk from 5.0.0 to 5.1.0.更新:正如 Sebastian 所说,现在您可以将 Audience-network-sdk 从 5.0.0 更新到 5.1.0。
Since October 31, Facebook released version 5.1 of the Audience Network SDK.自 10 月 31 日起,Facebook 发布了 Audience Network SDK 5.1 版。 Using
使用
implementation 'com.facebook.android:audience-network-sdk:5.1.0'
实现 'com.facebook.android:audience-network-sdk:5.1.0'
fixed the issue for me.为我解决了这个问题。
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.如果我正确阅读了文件树,则您的
AndroidManifest.xml
文件位于res
文件夹中,这可能是您看到错误的原因。 Try to put the file in {ProjectName}/app/src/main
and rebuild the project.尝试将文件放在
{ProjectName}/app/src/main
并重建项目。
I ran into the same bug.我遇到了同样的错误。 Had to change a few things before getting a working build.
在获得工作版本之前必须更改一些内容。 For me it was:
对我来说是:
I hope this helps you.我希望这可以帮助你。
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.
我没有使用上面提到的 facebook 库,而是使用了其他一些库,由于构建的信息较少,我无法弄清楚。
I had one sub module (say module1
) which was including another library, which further had many dependencies.我有一个子模块(比如
module1
),它包含另一个库,该库进一步具有许多依赖项。 So I put,所以我把,
packagingOptions {
exclude 'AndroidManifest.xml'
}
In the build.gradle
of module1
and then the issue was resolved.在
build.gradle
的module1
,然后问题就解决了。
Just writing this answer to convey putting in app
's build.gradle
might not solve issue for all the cases.只是写这个答案来传达放入
app
的build.gradle
可能无法解决所有情况下的问题。
Thanks a lot @Jason for showing the right direction.非常感谢@Jason 指出正确的方向。
To those who what to know why facebook library has such issue:对于那些知道为什么 facebook 图书馆有这样的问题的人:
You can download the aar file from maven respository , then drag it into Android Studio and expand the classes.jar
.您可以从maven资源库下载 aar 文件,然后将其拖入 Android Studio 并展开
classes.jar
。 You would see there is a manifest file inside the classes.jar
.您会看到
classes.jar
中有一个清单文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.