I try to use my application, which contains usage of Android Backup Service with my own BackupAgent, on Android Emulator. But backup doesn’t work, despite of permission written in AndroidManifest.xml.
Permission: <uses-permission android:name=”android.permission.BACKUP”/>
Warning in log: 09-17 09:05:58.553: WARN/PackageManager(73): Not granting permission android.permission.BACKUP to package my.package (protectionLevel=3 flags=0x1be46)
Exception in log (when I try to call requestRestore()):
java.lang.SecurityException: getCurrentTransport: Neither user 10040 nor current process has android.permission.BACKUP.
What’s wrong in my code?
UPD: My manifest
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="my.package">
<uses-permission android:name="android.permission.BACKUP"/>
<application android:name="my.package.MyApplicationName" android:backupAgent="my.package.MyBackupAgent">
<meta-data android:name="com.google.android.backup.api_key" android:value="my_backup_api_key">
</application>
</manifest>
Official Android documentation of Manifest permissions knows nothing about permission
So, you should remove it from your Manifest. Android Backup Service doesn’t require additional permissions.
However, specified permission can be used, but only by “system” applications, because it requires
PROTECTION_SIGNATUREorPROTECTION_SIGNATURE_OR_SYSTEMlevel of permissions.Such permission needed only when calling method BackupManager.dataChanged(String packageName), but usually this method is not needed when implementing Backup Service.