cancel
Showing results for 
Search instead for 
Did you mean: 

In SAP BTP Android SDK SecureKeyValueStore is not working

ragisaikiran
Explorer
0 Kudos

Hi Team
I am facing issue with SecureKeyValueStore provided by the SAP BTP SDK.
Below is the code snippet I have used.

EncryptionUtil.initialize(context);
byte[] myEncryptionKey = EncryptionUtil.getEncryptionKey("alias_for_preferences_store");
SecureKeyValueStore myStore = new SecureKeyValueStore(context, "preference_store_name");
myStore.open(myEncryptionKey);

Here I am getting chashes to generate the encryption key.
Can anyone please help me.

Note: I observed this is only crashing in one specific device(Oneplus 7T)

MarkFogle
Advisor
Advisor
0 Kudos

Hi Sai,

Can you include some information from the call stack when the crash occurs?

Thanks,

Mark Fogle

SAP BTP SDK for Android

ragisaikiran
Explorer
0 Kudos

Hi Mark Fogle,

This is the code I am using:
EncryptionUtil.initialize(context);
byte[] myEncryptionKey = EncryptionUtil.getEncryptionKey("aliasForPreferenceStore");
myStore = new SecureKeyValueStore(context, "secure_sdk_prefs");
myStore.open(myEncryptionKey);


Here when I am trying to execute below line then I am getting crash
byte[] myEncryptionKey = EncryptionUtil.getEncryptionKey("aliasForPreferenceStore");


Carsh is:
KeyStore entry does not exist.

flyingfish
Explorer
0 Kudos

Hi Sai,

Can you provide the information about the OS? Is it ColorOS or OxygenOS? Which version is it?

Thanks,

Bruce

ragisaikiran
Explorer
0 Kudos

Hi flyingfish

Android OxygenOS version 12

Device Model: OnePlus 7T

hai-yan_zhao
Advisor
Advisor
0 Kudos

Hi Sai,

Please try to set android:allowBackup="false" in client app's AndroidManifest.xml file. Then uninstall app, install app again and see if this crash also happens.

I met a similar crash by uninstalling and installling client app. My workaround was to go to app's info page and clear storage. Then open app again, crash was gone.

If set android:allowBackup="true" in client app's AndroidManifest.xml file, please refer to this documentation: https://help.sap.com/doc/f53c64b93e5140918d676b927a3cd65b/Cloud/en-US/docs-en/guides/features/securi.... From this doc, we need to create a xml file to define backup rules. In this xml file, add <exclude> elements to exclude files for the sharedpref and database. The names of sharedpref and database files can be checked in Device File Explorer.

Best regards,

Hai-Yan Zhao

ragisaikiran
Explorer
0 Kudos

Hi hai-yan.zhao ,

It is working fine.
Below code I have used.

String ENCRYPTION_KEY_ALIAS = "encryption_key_alias";
String SECURE_PREFERENCES_NAME = "secure_sdk_prefs

EncryptionUtil.initialize(context);
byte[] myEncryptionKey = EncryptionUtil.getEncryptionKey(ENCRYPTION_KEY_ALIAS);
myStore = new SecureKeyValueStore(context, SECURE_PREFERENCES_NAME);
myStore.open(myEncryptionKey);

In Manifest:-

android:allowBackup="true"
android:fullBackupContent="@xml/backup_rules"
tools:replace="android:allowBackup"

backup_rules.xml:-

<?xml version="1.0" encoding="utf-8"?>
<full-backup-content>
<exclude domain="sharedpref" path="encryption_key_alias_sharedPreference##.xml" />
<exclude domain="database" path="secure_sdk_prefs" />
</full-backup-content>

Thanks
ragisaikiran

Accepted Solutions (0)

Answers (0)