由于 AndroidManifest.xml 文件的问题,无法构建 APK。

3
出现了以下错误:

我的AndroidManifest.xml中的代码如下:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.avi12.palindrome"
    android:versionCode="59"
    android:versionName="3.3" >

    <uses-sdk
        android:minSdkVersion="14"
        android:targetSdkVersion="27" />

    <application
        android:allowBackup="true"
        android:debuggable="true"
        android:fullBackupContent=""
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.avi12.palindrome.MainActivity"
            android:label="@string/app_name"
            android:screenOrientation="portrait" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <!--
             ATTENTION: This was auto-generated to add Google Play services to your project for
             App Indexing.  See https://g.co/AppIndexing/AndroidStudio for more information.
        -->
        <meta-data
            android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version" />

        <activity
            android:name="com.google.android.gms.common.api.GoogleApiActivity"
            android:exported="false"
            android:theme="@android:style/Theme.Translucent.NoTitleBar" />

        <provider
            android:name="com.google.firebase.provider.FirebaseInitProvider"
            android:authorities="com.avi12.palindrome.firebaseinitprovider"
            android:exported="false"
            android:initOrder="100" />

        <meta-data
            android:name="android.arch.lifecycle.VERSION"
            android:value="27.0.0-SNAPSHOT" />
    </application>

</manifest>

我尝试过清理项目,但没有起作用,
我不确定是什么导致了这些错误。
结果就是,我无法构建APK。
请问如何解决?谢谢!

2个回答

7
`android:fullBackupContent=""` 不能为空,因此应该指向包含定义备份策略规则的XML文件。 文档中提到,在`AndroidManifest.xml`文件中,需要在``元素中添加`android:fullBackupContent`属性。该属性指向一个包含备份规则的XML文件。例如:
<application ...
    android:fullBackupContent="@xml/my_backup_rules">
  </app>

res/xml/ 目录下创建名为 my_backup_rules.xml 的 XML 文件。在文件内部,使用 <include><exclude> 元素添加规则。以下示例备份所有共享首选项,但不包括 device.xml
<?xml version="1.0" encoding="utf-8"?>
<full-backup-content>
    <include domain="sharedpref" path="."/>
    <exclude domain="sharedpref" path="device.xml"/>
</full-backup-content>

或者
从错误日志中,您还可以定义一个boolean值,如下所示:

// hasn't test it but
// judging from error android:fullBackupContent (attr)reference|boolean
android:fullBackupContent=false 

好的,我没有把代码作为图片展示,这是链接:https://i.imgur.com/baBNvZW.png。还有其他想法吗? - avi12
@avi12,你需要删除allowbackup,不要使用空值标签,并且“主要问题是”要定位你项目中的清单文件,当前的清单文件是由Studio生成的,更改将不会产生任何效果。 - Pavneet_Singh
打开项目层次结构中的清单并对其进行更改,在顶部读取您图片中的消息(在评论中发布)“文件属于构建...不应进行编辑”。 - Pavneet_Singh
看起来你的第一条评论解决了问题。谢谢! - avi12
@avi12,我很高兴我能帮到你。 - Pavneet_Singh

2
要么从您的清单中删除 android:fullBackupContent="",要么创建您的 XML 规则并像这样添加它们 android:fullBackupContent="@xml/my_backup_rules",其中 my_backup_rules 是一个 XML 文件,您可以在其中设置规则来定义要备份的文件。

https://developer.android.com/guide/topics/data/autobackup.html

访问此链接以获取更多信息。


有一个相当奇怪的问题导致这个解决方案没有帮助:https://i.imgur.com/baBNvZW.png - avi12

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接