Signal crashes after using a TitaniumBackup
I have the same problem as @Reiuiji in #7386 a downgrade to 4.15.5 helped in that I'm now able to access my messages again and chat, but the update still lets Signal crash.
03-03 11:51:27.283 21676 21676 D AndroidRuntime: Shutting down VM
03-03 11:51:27.284 21676 21676 E AndroidRuntime: FATAL EXCEPTION: main
03-03 11:51:27.284 21676 21676 E AndroidRuntime: Process: org.thoughtcrime.securesms, PID: 21676
03-03 11:51:27.284 21676 21676 E AndroidRuntime: java.lang.RuntimeException: Unable to create application org.thoughtcrime.securesms.ApplicationContext: java.lang.NullPointerException: Attempt to invoke virtual method 'javax.crypto.SecretKey java.security.KeyStore$SecretKeyEntry.getSecretKey()' on a null object reference
03-03 11:51:27.284 21676 21676 E AndroidRuntime: at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5743)
03-03 11:51:27.284 21676 21676 E AndroidRuntime: at android.app.ActivityThread.-wrap1(Unknown Source:0)
03-03 11:51:27.284 21676 21676 E AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1656)
03-03 11:51:27.284 21676 21676 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:106)
03-03 11:51:27.284 21676 21676 E AndroidRuntime: at android.os.Looper.loop(Looper.java:164)
03-03 11:51:27.284 21676 21676 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:6494)
03-03 11:51:27.284 21676 21676 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
03-03 11:51:27.284 21676 21676 E AndroidRuntime: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:440)
03-03 11:51:27.284 21676 21676 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
03-03 11:51:27.284 21676 21676 E AndroidRuntime: Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'javax.crypto.SecretKey java.security.KeyStore$SecretKeyEntry.getSecretKey()' on a null object reference
03-03 11:51:27.284 21676 21676 E AndroidRuntime: at org.thoughtcrime.securesms.crypto.KeyStoreHelper.getKeyStoreEntry(KeyStoreHelper.java:106)
03-03 11:51:27.284 21676 21676 E AndroidRuntime: at org.thoughtcrime.securesms.crypto.KeyStoreHelper.unseal(KeyStoreHelper.java:65)
03-03 11:51:27.284 21676 21676 E AndroidRuntime: at org.thoughtcrime.securesms.crypto.DatabaseSecretProvider.getEncryptedDatabaseSecret(DatabaseSecretProvider.java:58)
03-03 11:51:27.284 21676 21676 E AndroidRuntime: at org.thoughtcrime.securesms.crypto.DatabaseSecretProvider.getOrCreateDatabaseSecret(DatabaseSecretProvider.java:29)
03-03 11:51:27.284 21676 21676 E AndroidRuntime: at org.thoughtcrime.securesms.database.DatabaseFactory.<init>(DatabaseFactory.java:121)
03-03 11:51:27.284 21676 21676 E AndroidRuntime: at org.thoughtcrime.securesms.database.DatabaseFactory.getInstance(DatabaseFactory.java:60)
03-03 11:51:27.284 21676 21676 E AndroidRuntime: at org.thoughtcrime.securesms.database.DatabaseFactory.getSmsDatabase(DatabaseFactory.java:75)
03-03 11:51:27.284 21676 21676 E AndroidRuntime: at org.thoughtcrime.securesms.service.ExpiringMessageManager.<init>(ExpiringMessageManager.java:29)
03-03 11:51:27.284 21676 21676 E AndroidRuntime: at org.thoughtcrime.securesms.ApplicationContext.initializeExpiringMessageManager(ApplicationContext.java:151)
03-03 11:51:27.284 21676 21676 E AndroidRuntime: at org.thoughtcrime.securesms.ApplicationContext.onCreate(ApplicationContext.java:86)
03-03 11:51:27.284 21676 21676 E AndroidRuntime: at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1119)
03-03 11:51:27.284 21676 21676 E AndroidRuntime: at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5740)
03-03 11:51:27.284 21676 21676 E AndroidRuntime: ... 8 more
03-03 11:51:27.291 1290 7142 W ActivityManager: Force finishing activity org.thoughtcrime.securesms/.ConversationListActivity
Anything I can do to help fix this/debug this? (I opened up a new bug report since the old one was solved for the initial poster)
Yes: you can try my build that allows the database key to be restored, like when you want to transfer it to a new device, and when 4.17 comes out you can use the new backup format.
My build of 4.16.9 can be found at https://mega.nz/#!0I4BxYhD!OFLrEXbISDg_L1Hjg-kQMZcGt796MaS02ce8x2jn29M , if you prefer to build it yourself, these files ware changed in the official 4.16.9 source: https://mega.nz/#!RdBVzZLR!ZriJT8CqOwM-3x2fRP6KLT1ceMqgfEavCf7O_lLtLRU
Of course, this assumes you can install apk's with a different signature on top of each other but since you need root to use TB anyway that should not be a problem.
https://github.com/signalapp/Signal-Android/issues/7400#issuecomment-363632680
It seems Moxie isn't all too interested in getting TB to work well with Signal.
@johanw666 thx for the source and apk. Installed it, but get the same crash on startup with it. If only I had known of this change before making a backup with TB and flashing a new rom. Anything else I could try?
TiBackup has never been supported, it will cause many problems when used with Signal. The Signal DB is now encrypted with a key that's kept in the Android KeyStore, so that's not included in your TiBackup.
@moxie0 I can still access my messages through an older version of Signal so my messages obviously didn't get encrypted with the new key yet. So it should be still possible to "fix" my installation that I can update it later shouldn't it?
@BlackLotus Yes, you should be able to get from where you are to a clean upgrade. You'll have to delete the migrated database and reset a number of shared prefs. That's also obviously unsupported, though, so you'll have to dig through the code to make that work. At some point I posted a "cleaner" APK in a different thread, if you can find that it might work for you.
Yeah the cleaner apk was posted in the thread I linked to in post one. I think I really will have to dig through the code to fix this for me. I will post my "working solution" in here (if I find one).
@BlackLotus I didn't realize you don't have a TB of the 4.15 database. The cleaner apk was mentioned in the thread https://github.com/signalapp/Signal-Android/issues/7386 . If you use that you can use my version to backup the files.
The reason 4.15 still shows the messages is that the old databases with the 4.15 messages in them are not deleted during upgrade.
Ok here is what I tried: Installed the cleaning apk https://mega.nz/#!c11hGKYZ!TratUam6GvssC2KGPG3iVx2sKdF67-_y9gKMVqOYpj0 over my "working" signal 4.15.5 setup.
03-03 20:37:22.603 1295 3045 W ActivityManager: Unable to start service Intent { act=com.google.android.gms.ads.identifier.service.START pkg=com.google.android.gms } U=0: not found
03-03 20:37:22.657 6302 6318 W MainActivity: Deleting signal.db: true
03-03 20:37:22.657 6302 6318 W MainActivity: Setting preference...
03-03 20:37:22.677 6302 6318 W MainActivity: Done!
03-03 20:37:22.776 1295 1346 I ActivityManager: Displayed org.thoughtcrime.securesms/.MainActivity: +228ms
Saw the hello world, disabled signature checking sigh and installed your version over it and sadly still got the same error.
03-03 20:41:28.098 1295 3316 I ActivityManager: Start proc 6796:org.thoughtcrime.securesms/u0a150 for activity org.thoughtcrime.securesms/.RoutingActivity
03-03 20:41:28.107 1295 1423 I ActivityManager: Config changes=480 {1.0 262mcc7mnc [de_DE] ldltr sw360dp w640dp h336dp 480dpi nrml long land finger -keyb/v/h -nav/h appBounds=Rect(0, 0 - 1920, 1080) s.9}
03-03 20:41:28.133 1295 1423 I ActivityManager: Override config changes=480 {1.0 262mcc7mnc [de_DE] ldltr sw360dp w640dp h336dp 480dpi nrml long land finger -keyb/v/h -nav/h appBounds=Rect(0, 0 - 1920, 1080) s.9} for displayId=0
03-03 20:41:28.177 1295 1443 I InputReader: Reconfiguring input devices. changes=0x00000004
03-03 20:41:28.177 1295 1443 I InputReader: Device reconfigured: id=8, name='synaptics,s3320', size 1080x1920, orientation 1, mode 1, display id 0
03-03 20:41:28.194 4985 4985 D GeckoApplication: onConfigurationChanged: de_DE, background: false
03-03 20:41:28.195 4985 4985 D GeckoLocales: No selected locale. No correction needed.
03-03 20:41:28.209 1295 5581 W ActivityManager: Unable to start service Intent { act=com.google.android.gms.ads.identifier.service.START pkg=com.google.android.gms } U=0: not found
03-03 20:41:28.224 6796 6796 I MultiDex: VM with version 2.1.0 has multidex support
03-03 20:41:28.224 6796 6796 I MultiDex: Installing application
03-03 20:41:28.224 6796 6796 I MultiDex: VM has multidex support, MultiDex support library is disabled.
03-03 20:41:28.230 6796 6796 W PartProvider: onCreate()
03-03 20:41:28.255 1855 1855 D StatusBar: disable<e i a s b h r c s q >
03-03 20:41:28.265 6796 6796 D AndroidRuntime: Shutting down VM
03-03 20:41:28.265 6796 6796 E AndroidRuntime: FATAL EXCEPTION: main
03-03 20:41:28.265 6796 6796 E AndroidRuntime: Process: org.thoughtcrime.securesms, PID: 6796
03-03 20:41:28.265 6796 6796 E AndroidRuntime: java.lang.RuntimeException: Unable to create application org.thoughtcrime.securesms.ApplicationContext: java.lang.NullPointerException: Attempt to invoke virtual method 'javax.crypto.SecretKey java.security.KeyStore$SecretKeyEntry.getSecretKey()' on a null object reference
03-03 20:41:28.265 6796 6796 E AndroidRuntime: at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5743)
03-03 20:41:28.265 6796 6796 E AndroidRuntime: at android.app.ActivityThread.-wrap1(Unknown Source:0)
03-03 20:41:28.265 6796 6796 E AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1656)
03-03 20:41:28.265 6796 6796 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:106)
03-03 20:41:28.265 6796 6796 E AndroidRuntime: at android.os.Looper.loop(Looper.java:164)
03-03 20:41:28.265 6796 6796 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:6494)
03-03 20:41:28.265 6796 6796 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
03-03 20:41:28.265 6796 6796 E AndroidRuntime: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:440)
03-03 20:41:28.265 6796 6796 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
03-03 20:41:28.265 6796 6796 E AndroidRuntime: Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'javax.crypto.SecretKey java.security.KeyStore$SecretKeyEntry.getSecretKey()' on a null object reference
03-03 20:41:28.265 6796 6796 E AndroidRuntime: at org.thoughtcrime.securesms.crypto.KeyStoreHelper.getKeyStoreEntry(KeyStoreHelper.java:106)
03-03 20:41:28.265 6796 6796 E AndroidRuntime: at org.thoughtcrime.securesms.crypto.KeyStoreHelper.unseal(KeyStoreHelper.java:65)
03-03 20:41:28.265 6796 6796 E AndroidRuntime: at org.thoughtcrime.securesms.crypto.DatabaseSecretProvider.getEncryptedDatabaseSecret(DatabaseSecretProvider.java:58)
03-03 20:41:28.265 6796 6796 E AndroidRuntime: at org.thoughtcrime.securesms.crypto.DatabaseSecretProvider.getOrCreateDatabaseSecret(DatabaseSecretProvider.java:29)
03-03 20:41:28.265 6796 6796 E AndroidRuntime: at org.thoughtcrime.securesms.database.DatabaseFactory.<init>(DatabaseFactory.java:121)
03-03 20:41:28.265 6796 6796 E AndroidRuntime: at org.thoughtcrime.securesms.database.DatabaseFactory.getInstance(DatabaseFactory.java:60)
03-03 20:41:28.265 6796 6796 E AndroidRuntime: at org.thoughtcrime.securesms.database.DatabaseFactory.getSmsDatabase(DatabaseFactory.java:75)
03-03 20:41:28.265 6796 6796 E AndroidRuntime: at org.thoughtcrime.securesms.service.ExpiringMessageManager.<init>(ExpiringMessageManager.java:29)
03-03 20:41:28.265 6796 6796 E AndroidRuntime: at org.thoughtcrime.securesms.ApplicationContext.initializeExpiringMessageManager(ApplicationContext.java:153)
03-03 20:41:28.265 6796 6796 E AndroidRuntime: at org.thoughtcrime.securesms.ApplicationContext.onCreate(ApplicationContext.java:87)
03-03 20:41:28.265 6796 6796 E AndroidRuntime: at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1119)
03-03 20:41:28.265 6796 6796 E AndroidRuntime: at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5740)
03-03 20:41:28.265 6796 6796 E AndroidRuntime: ... 8 more
03-03 20:41:28.268 1295 6820 W ActivityManager: Force finishing activity org.thoughtcrime.securesms/.RoutingActivity
03-03 20:41:28.291 1295 6820 I WindowManager: Screen frozen for +205ms due to Window{468729c u0 StatusBar}
03-03 20:41:28.300 1295 1330 I ActivityManager: Showing crash dialog for package org.thoughtcrime.securesms u0```
Ah yes, that could be caused if the 4.16 data is still there. Install the cleaning apk, run it, and remove (or move to some other place to be sure) the new database file /data/data/org.thoughtcrime.smssecure/databases/signal.db.
You should see an "Updating database" if you install a 4.16 version after the cleaner apk.
Ok for everyone who has the same problem as me I got signal working again. I had to remove pref_database_encrypted_secret and pref_attachment_encrypted_secret in the shared prefs. Thank you @johanw666 and thank you @moxie0 for supporting me. Keep up the good work and thanks again.
Ok here the summary 4.15.5 installed and replaced the data of it with the 4.16 backup. Installed the cleaner mentioned above. Edited the shared preferences and removed pref_database_encrypted_secret and pref_attachment_encrypted_secret. Updated it to the newest version and got the migration going.
So I have this crash on Signal 4.17.3 (beta) following an update to Android 7.1.2 from 3-day-old Android 7.1.2 (yes, the same thing)
Attempt to invoke virtual method 'javax.crypto.SecretKey java.security.KeyStore$SecretKeyEntry.getSecretKey()' on a null object reference
I do not use Titanium Backup and did not go back to a previous version of anything. I did update Android from a new source build and now Signal crashes.
The previous installed Android was built 3 days ago. I haven't had this issue before. The version of Signal I used has remained constant between Android updates.
I do remember the database being upgraded previously-- no idea why the contents of the android keystore would be unavailable now... but in any event shouldn't the NPE at least be caught and handled w/o a crash?
Update: this may be a lineageos issue: https://review.lineageos.org/#/c/208870/
I did update Android from a new source build
Android or LineageOS? Someone else has already reported that LineageOS seems to wipe / damage the contents of the Android keystore on upgrade. So upgrading LineageOS without a backup means no decipherable messages.
Yeah LineageOS checked in a bunch of security fixes that seems to wipe the keystore on some devices that use qcom's hardware keystore. At least it did on my Note 4.
See comment: "IMO we should ship this topic first (at least the actual vulnerability fixes!), then handle the issue for those devices that have active hardware keystores." Sigh.
Did want to mention it in this closed issue in case anyone winds up here via a search of the error. I didn't try reverting anything- just reinstalled signal and let everyone freak out about the new safety numbers.
@fat-tire this is freaking massive. Seems like each and every signal instance will be utterly destroyed by LOS upgrade? Sounds like a PR disaster for Signal.
To me it sounds like it is a Lineage problem, not a Signal problem.
https://jira.lineageos.org/browse/BUGBASH-590?focusedCommentId=23831&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-23831
@blacklotus i did a backup from 4.19.3 through Titanium, coz simply the backup from signal did not worked, of course it crashed if i restore the data, but when i downgrade to 4.15.5 the app did not crashed, but the were no messages too, I followed your way to restore the messages, but no use, any idea where to start? There are extremely important messages there in the backup
@DBGT-87 Yes, since 4.16 Signal uses an encrypted database with keys encrypted with a key in the Android keystore. The old database was removed some versions agoo. If you still have the original device, have it rooted and did not uninstall Signal there might be a method to recover: see https://whispersystems.discoursehosting.net/t/howto-manual-backup-restore-if-full-backup-does-not-work/2462
@johanw666 thank you, it is on the same phone! And I did a clean installation. Are there any chances left? I copied the passphrase but did not back it up from the app itself.
@DBGT-87 this situation is a bit unclear to me. If you ONLY have one device, made a TI backup and removed the original Signal installation you have a problem because with uninstalling Signal you also removed its keys from the Android keystore. In that case your messages are lost unless you can bruteforce a 256 bit key, and even a quantum computer cannot do that (QC reduces the keyspace of a symmetric cipher only by a sqrt, wich is still too large to brute force).