Androidアプリで下記のSalesforceモバイルライブラリを利用するにあたって、  
Androidの3台中１台はプッシュ通知が届かない。

<https://github.com/forcedotcom/SalesforceMobileSDK-Android>

発生したAndroid端末は  
・機種：Xperia 10 IV  
・Android OS：12

問題発生前は通常にプッシュ通知は届けますが、  
アプリを複数回インストール・アンインストールしてから問題が発生されてます。  
同じソースコードを別のアプリにリリースしたら、OKです。  
別の端末は無事にプッシュ通知の受信が可能。

現状は端末IDの復号化処理で例外が発生されSalesforceプッシュ通知サーバーの端末ID登録が失敗されます。  
ログは下記のようです。  
お手数ですが解決方法をご存知の方、よろしくお願いします。

```

    E  keystore2::error: In KeystoreOperation::finish   
        
    Caused by:  
    0: In finish: KeyMint::finish failed.   
    1: Error::Km(ErrorCode(-1000))  
    E  Error during asymmetric decryption   
    javax.crypto.IllegalBlockSizeException  
    at android.security.keystore2.AndroidKeyStoreCipherSpiBase.engineDoFinal(AndroidKeyStoreCipherSpiBase.java:613)
    at javax.crypto.Cipher.doFinal(Cipher.java:2056)
    at com.salesforce.androidsdk.analytics.security.Encryptor.decryptWithPrivateKey(Encryptor.java:530)
    at com.salesforce.androidsdk.analytics.security.Encryptor.decryptWithRSABytes(Encryptor.java:427)
    at com.salesforce.androidsdk.analytics.security.Encryptor.decryptWithRSA(Encryptor.java:408)
    at com.salesforce.androidsdk.security.SalesforceKeyGenerator.generateUniqueId(SalesforceKeyGenerator.java:164)
    at com.salesforce.androidsdk.security.SalesforceKeyGenerator.getUniqueId(SalesforceKeyGenerator.java:88)
    at com.salesforce.androidsdk.security.SalesforceKeyGenerator.getUniqueId(SalesforceKeyGenerator.java:77)
    at com.salesforce.androidsdk.security.SalesforceKeyGenerator.generateEncryptionKey(SalesforceKeyGenerator.java:145)
    at com.salesforce.androidsdk.security.SalesforceKeyGenerator.getEncryptionKey(SalesforceKeyGenerator.java:103)
    at com.salesforce.androidsdk.app.SalesforceSDKManager.getEncryptionKey(SalesforceSDKManager.java:1082)
    at com.salesforce.androidsdk.accounts.UserAccountManager.getCurrentAccount(UserAccountManager.java:224)
    at com.salesforce.androidsdk.accounts.UserAccountManager.getCurrentUser(UserAccountManager.java:174)
    at com.salesforce.androidsdk.accounts.UserAccountManager.getCachedCurrentUser(UserAccountManager.java:188)
    at com.salesforce.androidsdk.analytics.AnalyticsPublisherService.handleActionPublish(AnalyticsPublisherService.java:76)
    at com.salesforce.androidsdk.analytics.AnalyticsPublisherService.onHandleWork(AnalyticsPublisherService.java:67)
    at androidx.core.app.JobIntentService$CommandProcessor.doInBackground(JobIntentService.java:396)
    at androidx.core.app.JobIntentService$CommandProcessor.doInBackground(JobIntentService.java:387)
    at android.os.AsyncTask$3.call(AsyncTask.java:394)
    at java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1137)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:637)
    at java.lang.Thread.run(Thread.java:1012)
    Caused by: android.security.KeyStoreException: Unknown error    
    at android.security.KeyStore2.getKeyStoreException(KeyStore2.java:356)
    at android.security.KeyStoreOperation.handleExceptions(KeyStoreOperation.java:78)
    at android.security.KeyStoreOperation.finish(KeyStoreOperation.java:127)
    at android.security.keystore2.KeyStoreCryptoOperationChunkedStreamer$MainDataStream.finish(KeyStoreCryptoOperationChunkedStreamer.java:228)
    at android.security.keystore2.KeyStoreCryptoOperationChunkedStreamer.doFinal(KeyStoreCryptoOperationChunkedStreamer.java:181)
    at android.security.keystore2.AndroidKeyStoreCipherSpiBase.engineDoFinal(AndroidKeyStoreCipherSpiBase.java:603)
    at javax.crypto.Cipher.doFinal(Cipher.java:2056) 
    at com.salesforce.androidsdk.analytics.security.Encryptor.decryptWithPrivateKey(Encryptor.java:530) 
    at com.salesforce.androidsdk.analytics.security.Encryptor.decryptWithRSABytes(Encryptor.java:427) 
    at com.salesforce.androidsdk.analytics.security.Encryptor.decryptWithRSA(Encryptor.java:408) 
    at com.salesforce.androidsdk.security.SalesforceKeyGenerator.generateUniqueId(SalesforceKeyGenerator.java:164) 
    at com.salesforce.androidsdk.security.SalesforceKeyGenerator.getUniqueId(SalesforceKeyGenerator.java:88) 
    at com.salesforce.androidsdk.security.SalesforceKeyGenerator.getUniqueId(SalesforceKeyGenerator.java:77) 
    at com.salesforce.androidsdk.security.SalesforceKeyGenerator.generateEncryptionKey(SalesforceKeyGenerator.java:145) 
    at com.salesforce.androidsdk.security.SalesforceKeyGenerator.getEncryptionKey(SalesforceKeyGenerator.java:103) 
    at com.salesforce.androidsdk.app.SalesforceSDKManager.getEncryptionKey(SalesforceSDKManager.java:1082) 
    at com.salesforce.androidsdk.accounts.UserAccountManager.getCurrentAccount(UserAccountManager.java:224) 
    at com.salesforce.androidsdk.accounts.UserAccountManager.getCurrentUser(UserAccountManager.java:174) 
    at com.salesforce.androidsdk.accounts.UserAccountManager.getCachedCurrentUser(UserAccountManager.java:188) 
    at com.salesforce.androidsdk.analytics.AnalyticsPublisherService.handleActionPublish(AnalyticsPublisherService.java:76) 
    at com.salesforce.androidsdk.analytics.AnalyticsPublisherService.onHandleWork(AnalyticsPublisherService.java:67) 
    at androidx.core.app.JobIntentService$CommandProcessor.doInBackground(JobIntentService.java:396) 
    at androidx.core.app.JobIntentService$CommandProcessor.doInBackground(JobIntentService.java:387) 
    at android.os.AsyncTask$3.call(AsyncTask.java:394) 
    at java.util.concurrent.FutureTask.run(FutureTask.java:264) 
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1137) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:637) 
    at java.lang.Thread.run(Thread.java:1012) 
    E  Exception thrown while getting encryption key    
    java.lang.NullPointerException: Attempt to invoke virtual method 'byte[] java.lang.String.getBytes(java.nio.charset.Charset)' on a null object reference    
    at com.salesforce.androidsdk.security.SalesforceKeyGenerator.generateEncryptionKey(SalesforceKeyGenerator.java:146)
    at com.salesforce.androidsdk.security.SalesforceKeyGenerator.getEncryptionKey(SalesforceKeyGenerator.java:103)
    at com.salesforce.androidsdk.app.SalesforceSDKManager.getEncryptionKey(SalesforceSDKManager.java:1082)
    at com.salesforce.androidsdk.accounts.UserAccountManager.getCurrentAccount(UserAccountManager.java:224)
    at com.salesforce.androidsdk.accounts.UserAccountManager.getCurrentUser(UserAccountManager.java:174)
    at com.salesforce.androidsdk.accounts.UserAccountManager.getCachedCurrentUser(UserAccountManager.java:188)
    at com.salesforce.androidsdk.analytics.AnalyticsPublisherService.handleActionPublish(AnalyticsPublisherService.java:76)
    at com.salesforce.androidsdk.analytics.AnalyticsPublisherService.onHandleWork(AnalyticsPublisherService.java:67)
    at androidx.core.app.JobIntentService$CommandProcessor.doInBackground(JobIntentService.java:396)
    at androidx.core.app.JobIntentService$CommandProcessor.doInBackground(JobIntentService.java:387)
    at android.os.AsyncTask$3.call(AsyncTask.java:394)
    at java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1137)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:637)
    at java.lang.Thread.run(Thread.java:1012)
    E  rsp_header->status: -1000    
    E  keystore2::error: In KeystoreOperation::finish   
        
    Caused by:  
    0: In finish: KeyMint::finish failed.   
    1: Error::Km(ErrorCode(-1000))  
    
    E  Error during asymmetric decryption   
    javax.crypto.IllegalBlockSizeException  
    at android.security.keystore2.AndroidKeyStoreCipherSpiBase.engineDoFinal(AndroidKeyStoreCipherSpiBase.java:613)
    at javax.crypto.Cipher.doFinal(Cipher.java:2056)
    at com.salesforce.androidsdk.analytics.security.Encryptor.decryptWithPrivateKey(Encryptor.java:530)
    at com.salesforce.androidsdk.analytics.security.Encryptor.decryptWithRSABytes(Encryptor.java:427)
    at com.salesforce.androidsdk.analytics.security.Encryptor.decryptWithRSA(Encryptor.java:408)
    at com.salesforce.androidsdk.security.SalesforceKeyGenerator.generateUniqueId(SalesforceKeyGenerator.java:164)
    at com.salesforce.androidsdk.security.SalesforceKeyGenerator.getUniqueId(SalesforceKeyGenerator.java:88)
    at com.salesforce.androidsdk.security.SalesforceKeyGenerator.getUniqueId(SalesforceKeyGenerator.java:77)
    at com.salesforce.androidsdk.push.PushService.getRSAPublicKey(PushService.java:354)
    at com.salesforce.androidsdk.push.PushService.registerSFDCPushNotification(PushService.java:309)
    at com.salesforce.androidsdk.push.PushService.onRegistered(PushService.java:216)
    at com.salesforce.androidsdk.push.PushService.performRegistrationChange(PushService.java:184)
    at com.salesforce.androidsdk.push.PushService.onHandleWork(PushService.java:174)
    at androidx.core.app.JobIntentService$CommandProcessor.doInBackground(JobIntentService.java:396)
    at androidx.core.app.JobIntentService$CommandProcessor.doInBackground(JobIntentService.java:387)
    at android.os.AsyncTask$3.call(AsyncTask.java:394)
    at java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1137)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:637)
    at java.lang.Thread.run(Thread.java:1012)
                                                                                                        Caused by: android.security.Exception: Unknown error    
    at android.security.KeyStore2.getKeyStoreException(KeyStore2.java:356)
    at android.security.KeyStoreOperation.handleExceptions(KeyStoreOperation.java:78)
    at android.security.KeyStoreOperation.finish(KeyStoreOperation.java:127)
    at android.security.keystore2.KeyStoreCryptoOperationChunkedStreamer$MainDataStream.finish(KeyStoreCryptoOperationChunkedStreamer.java:228)
    at android.security.keystore2.KeyStoreCryptoOperationChunkedStreamer.doFinal(KeyStoreCryptoOperationChunkedStreamer.java:181)
    at android.security.keystore2.AndroidKeyStoreCipherSpiBase.engineDoFinal(AndroidKeyStoreCipherSpiBase.java:603)
    at javax.crypto.Cipher.doFinal(Cipher.java:2056) 
    at com.salesforce.androidsdk.analytics.security.Encryptor.decryptWithPrivateKey(Encryptor.java:530) 
    at com.salesforce.androidsdk.analytics.security.Encryptor.decryptWithRSABytes(Encryptor.java:427) 
    at com.salesforce.androidsdk.analytics.security.Encryptor.decryptWithRSA(Encryptor.java:408) 
    at com.salesforce.androidsdk.security.SalesforceKeyGenerator.generateUniqueId(SalesforceKeyGenerator.java:164) 
    at com.salesforce.androidsdk.security.SalesforceKeyGenerator.getUniqueId(SalesforceKeyGenerator.java:88) 
    at com.salesforce.androidsdk.security.SalesforceKeyGenerator.getUniqueId(SalesforceKeyGenerator.java:77) 
    at com.salesforce.androidsdk.push.PushService.getRSAPublicKey(PushService.java:354) 
    at com.salesforce.androidsdk.push.PushService.registerSFDCPushNotification(PushService.java:309) 
    at com.salesforce.androidsdk.push.PushService.onRegistered(PushService.java:216) 
    at com.salesforce.androidsdk.push.PushService.performRegistrationChange(PushService.java:184) 
    at com.salesforce.androidsdk.push.PushService.onHandleWork(PushService.java:174) 
    at androidx.core.app.JobIntentService$CommandProcessor.doInBackground(JobIntentService.java:396) 
    at androidx.core.app.JobIntentService$CommandProcessor.doInBackground(JobIntentService.java:387) 
    at android.os.AsyncTask$3.call(AsyncTask.java:394) 
    at java.util.concurrent.FutureTask.run(FutureTask.java:264) 
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1137) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:637) 
    at java.lang.Thread.run(Thread.java:1012) 
    
    
     E  Push notification registration failed   
    java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.String.replaceAll(java.lang.String, java.lang.String)' on a null object reference  
    at com.salesforce.androidsdk.push.PushService.getRSAPublicKey(PushService.java:355)
    at com.salesforce.androidsdk.push.PushService.registerSFDCPushNotification(PushService.java:309)
    at com.salesforce.androidsdk.push.PushService.onRegistered(PushService.java:216)
    at com.salesforce.androidsdk.push.PushService.performRegistrationChange(PushService.java:184)
    at com.salesforce.androidsdk.push.PushService.onHandleWork(PushService.java:174)
    at androidx.core.app.JobIntentService$CommandProcessor.doInBackground(JobIntentService.java:396)
    at androidx.core.app.JobIntentService$CommandProcessor.doInBackground(JobIntentService.java:387)
    at android.os.AsyncTask$3.call(AsyncTask.java:394)
    at java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1137)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:637)
    at java.lang.Thread.run(Thread.java:1012)
    
```
CC BY-SA 4.0
2023-08-08T02:05:58.983
95882
2023-08-11T17:07:12.667
2023-08-11T17:07:12.667
3060
59412
question
android cordova push-notification
Salesforce Android Hybrid ライブラリを使ったアプリが特定端末でプッシュ通知が届かない