gpt4 book ai didi

android - 从完整备份中排除所选首选项文件的正确方法是什么?我收到 "is not in an included path"警告

转载 作者:行者123 更新时间:2023-12-04 02:14:10 26 4
gpt4 key购买 nike

我有一些偏好数据,不应该备份,因为它们在不同的设备上无效。

这些是我的Manifest.xml和备份规则文件。

list .xml

<application
android:name=".WeNoteApplication"
android:backupAgent="com.yocto.wenote.auto_backup.CustomBackupAgent"
android:fullBackupOnly="true"
android:allowBackup="true"
android:fullBackupContent="@xml/my_backup_rules"

my_backup_rules.xml
<?xml version="1.0" encoding="utf-8"?>
<full-backup-content>
<include domain="sharedpref" path="com.yocto.wenote_preferences.xml" />

<exclude domain="sharedpref" path="com.yocto.wenote.backup.Backuper.xml" />
</full-backup-content>

我想明确排除名称为 的首选项"com.yocto.wenote.backup.Backup"

我从 IDE 收到以下错误

enter image description here

com.yocto.wenote.backup.Backuper.xml is not in an included path



我可以知道为什么会这样吗?我如何才能确定将选定的首选项 XML 文件排除在备份之外?

之前提出过类似的问题: Android full backup: "file.xml is not in an included path"但是,没有解决办法。

最佳答案

您收到此错误是因为您排除的路径超出了备份中包含的路径。如果您指定任何自定义 include ,那么只有那些东西会被备份:

<include> - Specifies a file or folder to backup. By default, Auto Backup includes almost all app files. If you specify an element, the system no longer includes any files by default and backs up only the files specified. To include multiple files, use multiple elements.



文档 here .

在您的情况下, excludecom.yocto.wenote.backup.Backuper.xml不在 include路径 com.yocto.wenote_preferences.xml - 因此错误。

如果您检查生成错误消息的 lint 规则的代码,它将确认由于您的排除路径没有任何包含的前缀,您将进入 !hasPrefix。案子。

这里的相关部分:
    for (String includePath : included) {
if (excludePath.startsWith(includePath)) {
if (excludePath.equals(includePath)) {
Attr pathNode = exclude.getAttributeNode(ATTR_PATH);
assert pathNode != null;
Location location = context.getValueLocation(pathNode);
// Find corresponding include path so we can link to it in the
// chained location list
for (Element include : includes) {
Attr includePathNode = include.getAttributeNode(ATTR_PATH);
String includeDomain = include.getAttribute(ATTR_DOMAIN);
if (includePathNode != null
&& excludePath.equals(includePathNode.getValue())
&& domain.equals(includeDomain)) {
Location earlier = context.getLocation(includePathNode);
earlier.setMessage("Unnecessary/conflicting <include>");
location.setSecondary(earlier);
}
}
context.report(ISSUE, exclude, location,
String.format("Include `%1$s` is also excluded", excludePath));
}
hasPrefix = true;
break;
}
}
if (!hasPrefix) {
Attr pathNode = exclude.getAttributeNode(ATTR_PATH);
assert pathNode != null;
context.report(ISSUE, exclude, context.getValueLocation(pathNode),
String.format("`%1$s` is not in an included path", excludePath));
}

Full code listing

因此,在您的情况下,您根本不需要排除该文件,因为只有 com.yocto.wenote_preferences.xml包含在您的备份中。

您还可以为备份传输和 XML 解析打开详细日志记录,以便查看发生了什么:
adb shell setprop log.tag.GmsBackupTransport VERBOSE
adb shell setprop log.tag.BackupXmlParserLogging VERBOSE

关于android - 从完整备份中排除所选首选项文件的正确方法是什么?我收到 "is not in an included path"警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57911803/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com