17

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?

2
  • It simply says that your exclude nonceStorage.xml is not in any <include .. paths? Commented Nov 11, 2018 at 20:58
  • 1
    I want to exclude that file. And I think it's included in '.' path. This is just like example at developer.android.com/guide/topics/data/autobackup Commented Nov 11, 2018 at 21:01

3 Answers 3

10

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.

Sign up to request clarification or add additional context in comments.

3 Comments

Is it working fine in your case, by removing <include>?
@Suresh Yes. After uninstalling and then reinstalling, the app's content is back.
removing the include results in none of the shared preferences being included in the backup.
3

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.

Comments

0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.