我有一些首选项数据,由于它们在不同设备上无效,因此不应备份。
这些是我的Manifest.xml
备份规则文件。
my_backup_rules.xml
我想明确排除名称为“ com.yocto.wenote.backup.Backuper”的首选项
我从IDE中收到以下错误
com.yocto.wenote.backup.Backuper.xml
不在包含的路径中我可以知道为什么会这样吗?我当然如何才能排除备份的首选首选项XML文件?
之前出现过类似的问题:Android完全备份:“ file.xml不在包含的路径中”,但是,没有解决方案。
1> kenny_k..:您收到此错误的原因是您要排除的路径超出了备份中包含的路径。如果您指定任何custom
include
,那么将仅备份这些内容:
-指定要备份的文件或文件夹。默认情况下,自动备份包含几乎所有应用程序文件。如果指定元素,则系统默认不再包含任何文件,并且仅备份指定的文件。要包含多个文件,请使用多个元素。
文档在这里。
在您的情况下,
exclude
atcom.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"); 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)); } 完整代码清单
因此,就您而言,您根本不需要排除该文件,因为
com.yocto.wenote_preferences.xml
备份中仅包含该文件。您还可以为备份传输和XML解析打开详细日志记录,以便了解发生了什么:
adb shell setprop log.tag.GmsBackupTransport VERBOSE adb shell setprop log.tag.BackupXmlParserLogging VERBOSE