简体   繁体   English

Android App Bundle 构建错误:保留文件

[英]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:对我来说是:

  1. downgrade facebook audience-network-sdk from 5.0.0 to 4.28.2将 facebook 受众网络 SDK 从 5.0.0 降级到 4.28.2
  2. downgrade okio from 2.1.0 to 2.0.0将 okio 从 2.1.0 降级到 2.0.0
  3. update proguard config for okio, okhttp & retrofit更新 okio、okhttp 和改造的 proguard 配置
  4. not using R8不使用 R8

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.gradlemodule1 ,然后问题就解决了。

Just writing this answer to convey putting in app 's build.gradle might not solve issue for all the cases.只是写这个答案来传达放入appbuild.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.

相关问题 尝试构建android应用程序捆绑包时出现“使用保留文件或目录名称&#39;lib&#39;”错误 - “Uses reserved file or directory name 'lib'” error when trying to build android app bundle 无法使用 android 的 App Bundle 构建 Unity 应用程序。 文件使用保留文件或目录名称“res” - Can't build Unity app using App Bundle for android. File uses reserved file or directory name 'res' 我在 Android 中创建 App Bundle 时出错:使用保留文件或目录名称“res” - I am getting error in creating App Bundle in Android: uses reserved file or directory name 'res' 出现错误:文件“ic_launcher.png”使用保留文件或目录名称“res”。 在构建 Bundle 文件时 Android Studio - Getting Error: File 'ic_launcher.png' uses reserved file or directory name 'res'. while building Bundle file Android Studio Android App Bundle构建失败 - Android App Bundle build fails Android App Bundle构建错误: <fusing> 元素缺少“包含”属性 - Android App Bundle build Error: <fusing> element is missing the 'include' attribute 构建Android Bundle的问题-引发错误“文件&#39;root / lib / commons-io-2.4.jar&#39;使用保留的文件或目录名称&#39;lib&#39;” - Issue with building Android Bundle - throws error “File 'root/lib/commons-io-2.4.jar' uses reserved file or directory name 'lib'” Android Studio3.2 APK 构建错误 -&gt; 保留文件或目录名称“lib” - Android Studio3.2 APK Build Error -> reserved file or directory name 'lib' Android Bundle 构建错误:FileUsesReservedNameException - Android Bundle Build Error : FileUsesReservedNameException 在Android的应用程序内捆绑文件 - Bundle a file inside app in Android
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM