diff --git a/.travis.yml b/.travis.yml index c89402b..a591d12 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,10 +1,11 @@ language: android -jdk: oraclejdk7 +jdk: openjdk8 android: components: - build-tools-23.0.1 - android-23 + - android-18 - extra - sys-img-armeabi-v7a-android-18 @@ -14,7 +15,7 @@ install: # Emulator Management: Create, Start and Wait before_script: - echo no | android create avd --force -n test -t android-18 --abi armeabi-v7a - - emulator -avd test -no-skin -no-audio -no-window & + - emulator -avd test -engine classic -no-skin -no-audio -no-window & - android-wait-for-emulator - adb shell input keyevent 82 & diff --git a/library/src/main/java/in/co/ophio/secure/core/KeyStoreKeyGenerator.java b/library/src/main/java/in/co/ophio/secure/core/KeyStoreKeyGenerator.java index 1e5baf4..1d1da8a 100644 --- a/library/src/main/java/in/co/ophio/secure/core/KeyStoreKeyGenerator.java +++ b/library/src/main/java/in/co/ophio/secure/core/KeyStoreKeyGenerator.java @@ -41,14 +41,19 @@ private KeyStoreKeyGenerator(Application application, String filename) { this.isHardwareBacked = KeyChain.isBoundKeyAlgorithm("RSA"); this.keyFile = new File(application.getFilesDir(), filename); - try { - // Load secret key and ensure our root document is ready. - loadOrGenerateKeys(); - - } catch (IOException e) { - throw new IllegalStateException(e); - } catch (GeneralSecurityException e) { - throw new IllegalStateException(e); + //WORKAROUND for https://issuetracker.google.com/issues/37137351 + + for (int i = 0; i <= 2; i++) { + try { + // Load secret key and ensure our root document is ready. + loadOrGenerateKeys(); + + } catch (IOException | GeneralSecurityException e) { + keyFile.delete(); + if (i >= 2) { + throw new IllegalStateException("Failed to initialize KeyStoreKeyGenerator (failed to load security key)", e); // fatal error + } + } } }