Reputation: 4844
I've created backup rules file just like in example https://developer.android.com/guide/topics/data/autobackup:
<?xml version="1.0" encoding="utf-8"?>
<full-backup-content xmlns:android="http://schemas.android.com/apk/res/android">
<include
domain="sharedpref"
path="." />
<exclude
domain="sharedpref"
path="nonceStorage.xml" />
<exclude
domain="sharedpref"
path="localStorage.xml" />
</full-backup-content>
and Android Studio say's that there are errors:
Error:(8, 15) `nonceStorage.xml` is not in an included path [FullBackupContent]
Error:(11, 15) `localStorage.xml` is not in an included path [FullBackupContent]
Error message is totally uninformative and not googleable (almost all words are very short). Can anyone explain,what does this *** want from me? How to fix this issue?
Upvotes: 15
Views: 2053
Reputation: 7718
This is definitely a bug in Android Studio, but here is a very reasonable workaround.
You need to add the following tools:ignore
XML attribute to clear the errors.
<include domain="sharedpref" path="."/>
<exclude domain="sharedpref" path="nonceStorage.xml"
tools:ignore="FullBackupContent" />
<exclude domain="sharedpref" path="localStorage.xml"
tools:ignore="FullBackupContent" />
I've verified this results in the expected shared preferences. In other words, the XML is correct and the lint check is wrong.
When generating debug APKs, these attributes are not necessary (the build completes regardless), but they are necessary for when you do Android Studio's Generate Signed Bundle / APK, otherwise the build fails with those errors.
The other answer saying you can just remove <include domain="sharedpref" path="."/>
is incorrect. This will result in none of the shared preferences being included.
The bug has been raised here.
Upvotes: 3
Reputation: 76789
the error message tells, that there are no such files to exclude in domain sharedpref
:
Error:(8, 15) `nonceStorage.xml` is not in an included path [FullBackupContent]
Error:(11, 15) `localStorage.xml` is not in an included path [FullBackupContent]
possibly it is domain root
- but while not including that domain, no need to exclude them.
<?xml version="1.0" encoding="utf-8"?>
<full-backup-content>
<include domain="sharedpref" path="."/>
</full-backup-content>
use the "Device File Explorer" and go to /data/user/0/com.yourapp/shared_prefs
...
there you can see which files belong into which domain - or if they are even present there.
Upvotes: 0
Reputation: 4956
I guess this is an IDE bug because the example from doc:
<?xml version="1.0" encoding="utf-8"?>
<full-backup-content>
<include domain="sharedpref" path="."/>
<exclude domain="sharedpref" path="device.xml"/>
</full-backup-content>
shows the same error on device.xml
.
Removing the <include>
clears the error if you simply want to exclude some files because the doc says
By default, Auto Backup includes almost all app files.
Upvotes: 9