新的应用发布格式 Android App Bundle 是一种改进的应用打包方式。 Android App Bundle 让您可以更轻松地以更小的应用程序提供出色的体验,从而支持当今种类繁多的 Android 设备。您无需重构代码即可开始从较小的应用程序中获益。
我在尝试构建我的应用程序 Android Bundle 时遇到此错误:
File 'root/AndroidManifest.xml' uses reserved file or directory name 'AndroidManifest.xml'.
APK 生成工作正常。
这是我的项目文件结构:
这是我的 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>
最佳答案
在 Facebook 修复 SDK 之前,一个更简单的修复方法是将其添加到应用程序 build.gradle 的 android { } block 中的 packagingOptions:
android {
packagingOptions {
exclude 'AndroidManifest.xml' //This fixes a bug in FAN 5.0.1
}
}
我只能在构建 App Bundle 时确认这是否有效,我不知道常规 APK。
关于Android App Bundle 构建错误 : reserved file,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52500757/