还原期间备份代理签名不匹配

时间:2011-06-17 09:02:10

标签: android signature uid android-backup-service

[编辑]从我添加的所有信息来看,这可能是由于我的应用程序在同一个UID下注册自己作为新应用程序引起的,尽管在同一个apk中是相同的构建。任何想要开始修复的想法都将非常感谢

我已经使用Helper类在我的应用中实现了BackupAgent,因为我只想备份共享首选项文件。

似乎这样做的备份电话很好。如果我在应用程序执行dataChanged()后执行'bmgr run',我会在logcat中获得以下内容:

06-17 09:58:41.618: DEBUG/PerformBackupThread(303): starting agent for backup of BackupRequest{app=ApplicationInfo{40d66190 uk.co.randomicon.rstb} full=false}
06-17 09:58:41.618: DEBUG/BackupManagerService(303): awaiting agent for ApplicationInfo{40d66190 uk.co.randomicon.rstb}
06-17 09:58:41.628: DEBUG/BackupHelperDispatcher(6720): handling existing helper 'rstb_prefs' android.app.backup.SharedPreferencesBackupHelper@408864e8
06-17 09:58:41.628: DEBUG/BackupManagerService(303): agentConnected pkg=uk.co.randomicon.rstb agent=android.os.BinderProxy@40b2f328
06-17 09:58:41.638: DEBUG/PerformBackupThread(303): starting agent for backup of BackupRequest{app=ApplicationInfo{40d75cc0 uk.co.randomicon.rstb} full=false}
06-17 09:58:41.648: DEBUG/BackupManagerService(303): awaiting agent for ApplicationInfo{40d75cc0 uk.co.randomicon.rstb}
06-17 09:58:41.648: DEBUG/BackupHelperDispatcher(6720): handling existing helper 'rstb_prefs' android.app.backup.SharedPreferencesBackupHelper@40708660
06-17 09:58:41.648: DEBUG/BackupManagerService(303): agentConnected pkg=uk.co.randomicon.rstb agent=android.os.BinderProxy@40b08e50
06-17 09:58:41.668: DEBUG/PerformBackupThread(303): starting agent for backup of BackupRequest{app=ApplicationInfo{40d6b420 uk.co.randomicon.rstb} full=false}
06-17 09:58:41.668: DEBUG/BackupManagerService(303): awaiting agent for ApplicationInfo{40d6b420 uk.co.randomicon.rstb}
06-17 09:58:41.668: DEBUG/BackupHelperDispatcher(6720): handling existing helper 'rstb_prefs' android.app.backup.SharedPreferencesBackupHelper@40789930
06-17 09:58:41.668: DEBUG/BackupManagerService(303): agentConnected pkg=uk.co.randomicon.rstb agent=android.os.BinderProxy@40ae3b70
06-17 09:58:41.688: DEBUG/PerformBackupThread(303): starting agent for backup of BackupRequest{app=ApplicationInfo{40d92b38 uk.co.randomicon.rstb} full=false}
06-17 09:58:41.688: DEBUG/BackupManagerService(303): awaiting agent for ApplicationInfo{40d92b38 uk.co.randomicon.rstb}
06-17 09:58:41.688: DEBUG/BackupHelperDispatcher(6720): handling existing helper 'rstb_prefs' android.app.backup.SharedPreferencesBackupHelper@408521c0
06-17 09:58:41.688: DEBUG/BackupManagerService(303): agentConnected pkg=uk.co.randomicon.rstb agent=android.os.BinderProxy@40acfd20
06-17 09:58:41.708: DEBUG/PerformBackupThread(303): starting agent for backup of BackupRequest{app=ApplicationInfo{40dd4c50 uk.co.randomicon.rstb} full=false}
06-17 09:58:41.708: DEBUG/BackupManagerService(303): awaiting agent for ApplicationInfo{40dd4c50 uk.co.randomicon.rstb}
06-17 09:58:41.708: DEBUG/BackupManagerService(303): agentConnected pkg=uk.co.randomicon.rstb agent=android.os.BinderProxy@40ababb0
06-17 09:58:41.718: DEBUG/BackupHelperDispatcher(6720): handling existing helper 'rstb_prefs' android.app.backup.SharedPreferencesBackupHelper@40887ee0
06-17 09:58:41.728: DEBUG/PerformBackupThread(303): starting agent for backup of BackupRequest{app=ApplicationInfo{40d725b0 uk.co.randomicon.rstb} full=false}
06-17 09:58:41.728: DEBUG/BackupManagerService(303): awaiting agent for ApplicationInfo{40d725b0 uk.co.randomicon.rstb}
06-17 09:58:41.728: DEBUG/BackupManagerService(303): agentConnected pkg=uk.co.randomicon.rstb agent=android.os.BinderProxy@40aaa058
06-17 09:58:41.728: DEBUG/BackupHelperDispatcher(6720): handling existing helper 'rstb_prefs' android.app.backup.SharedPreferencesBackupHelper@40835bd0
06-17 09:58:41.738: DEBUG/PerformBackupThread(303): starting agent for backup of BackupRequest{app=ApplicationInfo{40da2cd8 uk.co.randomicon.rstb} full=false}
06-17 09:58:41.748: DEBUG/BackupManagerService(303): awaiting agent for ApplicationInfo{40da2cd8 uk.co.randomicon.rstb}
06-17 09:58:41.748: DEBUG/BackupHelperDispatcher(6720): handling existing helper 'rstb_prefs' android.app.backup.SharedPreferencesBackupHelper@408769b8
06-17 09:58:41.748: DEBUG/BackupManagerService(303): agentConnected pkg=uk.co.randomicon.rstb agent=android.os.BinderProxy@40a99a20
06-17 09:58:41.768: DEBUG/PerformBackupThread(303): starting agent for backup of BackupRequest{app=ApplicationInfo{40d451b8 uk.co.randomicon.rstb} full=false}
06-17 09:58:41.768: DEBUG/BackupManagerService(303): awaiting agent for ApplicationInfo{40d451b8 uk.co.randomicon.rstb}
06-17 09:58:41.768: DEBUG/BackupHelperDispatcher(6720): handling existing helper 'rstb_prefs' android.app.backup.SharedPreferencesBackupHelper@40708440
06-17 09:58:41.768: DEBUG/BackupManagerService(303): agentConnected pkg=uk.co.randomicon.rstb agent=android.os.BinderProxy@40a89c58

但是,即使立即执行,执行'bmgr restore'操作会导致logcat中出现以下内容:

06-17 09:38:36.002: DEBUG/BackupManagerService(303): MSG_RUN_RESTORE observer=android.app.backup.IRestoreObserver$Stub$Proxy@40c0ec50
06-17 09:38:36.682: WARN/BackupManagerService(303): Signature mismatch restoring uk.co.randomicon.rstb

恢复的控制台输出是:

restoreStarting: 2 packages
onUpdate: 0 = uk.co.randomicon.rstb
restoreFinished: 0
done

有什么想法吗?它显然是相同的版本和签名,因为我没有卸载/擦除/任何东西。我已经注册了备份服务,密钥正确,等等。

编辑:它似乎可以作为调试密钥签名版本正常工作,但在导出的,混淆的,zipaligned版本密钥签名apk上失败。如果我试图将数据从调试版本恢复到发布版本中,那对我来说是有意义的,但我不是。

edit2:尝试更改帮助程序名称等,我仍然得到相同的行为。调试密钥签名apk工作完美,可以备份,卸载,重新安装,它会自动恢复。发布密钥签名apk每次都这样做。尽管只有一个内部函数调用,我仍然有点关注使用不同@号的重复备份调用。然而,调试也会这样做,所以它不可能完全是那样。

dumpsys backup的输出显示我的包四次......

Backup Manager is enabled / provisioned / not pending init
Auto-restore is enabled
Last backup pass: 1308330167956 (now = 1308330359754)
  next scheduled: 1308333767956
Available transports:
  * com.google.android.backup/.BackupTransportService
       com.android.inputmethod.latin - 112 state bytes
       com.android.browser - 20 state bytes
       com.android.providers.userdictionary - 8 state bytes
       com.android.vending - 0 state bytes
       android - 172 state bytes
       com.zegoggles.smssync - 100 state bytes
       com.smartandroidapps.audiowidgetpro - 416 state bytes
       org.connectbot - 260 state bytes
       net.cachapa.libra - 96 state bytes
       com.icenta.sudoku.ui - 52 state bytes
       com.android.providers.settings - 36 state bytes
       @pm@ - 378 state bytes
       uk.co.randomicon.rstb - 164 state bytes
    android/com.android.internal.backup.LocalTransport
Pending init: 0
Participants:
  uid: 1000
    com.android.providers.settings
    android
  uid: 10000
    com.android.providers.userdictionary
  uid: 10002
    com.android.browser
  uid: 10022
    com.android.inputmethod.latin
  uid: 10045
    com.android.vending
  uid: 10050
    uk.co.randomicon.rstb
    uk.co.randomicon.rstb
    uk.co.randomicon.rstb
    uk.co.randomicon.rstb
  uid: 10058
    com.zegoggles.smssync
  uid: 10063
    org.connectbot
  uid: 10084
    net.cachapa.libra
  uid: 10094
    com.smartandroidapps.audiowidgetpro
  uid: 10111
    com.icenta.sudoku.ui
Ancestral packages: 8
    com.android.browser
    com.zegoggles.smssync
    org.connectbot
    android
    com.android.vending
    com.android.providers.userdictionary
    com.android.inputmethod.latin
    com.android.providers.settings
Ever backed up: 12
    org.connectbot
    com.zegoggles.smssync
    com.android.browser
    com.icenta.sudoku.ui
    com.smartandroidapps.audiowidgetpro
    com.android.vending
    android
    net.cachapa.libra
    uk.co.randomicon.rstb
    com.android.providers.userdictionary
    com.android.inputmethod.latin
    com.android.providers.settings
Pending backup: 0

edit3:一直在卸载和重新安装,不断在同一个UID下添加我的应用程序的新实例。它是来自同一个apk的相同应用程序的相同构建,但它只是在该列表中不断创建自己的新实例。这是正确的行为吗?查看BackupManager源代码后,看起来(如果我已经读得正确),在调试模式下,管理器并不真正关心签名,这可能就是为什么它运行正常。

3 个答案:

答案 0 :(得分:2)

从设置中禁用备份 - >隐私,它删除所有备份。然后启用它,一切都会再次起作用。

答案 1 :(得分:2)

我遇到了同样的问题而且bmgr wipe <transport> <package>没有解决它。

帮助我的是{strong>切换备份来自adb shell

bmgr enable false
bmgr enable true
bmgr run

顺便说一下。当我是“普通”用户时,它失败并出现此错误:

java.lang.SecurityException: uid 2000 does not have android.permission.UPDATE_APP_OPS_STATS.

切换到su的超级用户并传递操作。

答案 2 :(得分:1)

它只是修复了自己。所有多个实例都在那里,但它现在有效。突然停止抱怨签名不匹配。

经验教训,我想,如果你确定你做得对,就等一下:P