Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/kotlin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Kotlin Android即时应用程序中的Android密钥库崩溃_Kotlin_Encryption_Keystore_Android Keystore_Android Instant Apps - Fatal编程技术网

Kotlin Android即时应用程序中的Android密钥库崩溃

Kotlin Android即时应用程序中的Android密钥库崩溃,kotlin,encryption,keystore,android-keystore,android-instant-apps,Kotlin,Encryption,Keystore,Android Keystore,Android Instant Apps,在即时应用程序中运行此代码会使我的应用程序崩溃,并出现以下堆栈跟踪: val masterKey = MasterKey .Builder(applicationContext) .setKeyScheme(MasterKey.KeyScheme.AES256_GCM) .build() 我在StackOverflow中没有找到这个问题,但我在Google问题跟踪器中找到了它,但没有回应。因此,我创

在即时应用程序中运行此代码会使我的应用程序崩溃,并出现以下堆栈跟踪:

val masterKey =
            MasterKey
            .Builder(applicationContext)
            .setKeyScheme(MasterKey.KeyScheme.AES256_GCM)
            .build()
我在StackOverflow中没有找到这个问题,但我在Google问题跟踪器中找到了它,但没有回应。因此,我创建了一个问题,并向谷歌提交了更多信息

是否有人遇到此问题并能够解决它

我的工作环境是:

  • Mac OS 10.15.7
  • Android Studio 4.0.1
  • 三星A70
  • 安卓版本10

虽然这没有在developer.android论坛上正式记录,但对于即时应用程序,AndroidKeyStore访问似乎受到限制。我发现了这个链接


这很奇怪,密钥库受到限制,而且没有android文档对此进行解释。我不确定访问KeyStore的替代方案,因为我们的常规应用程序(非即时)对KeyStore有很多依赖,我想不出更好的选择。期待您的建议

虽然这没有在developer.android论坛上正式记录,但对于即时应用程序,AndroidKeyStore访问似乎受到限制。我发现了这个链接

这很奇怪,密钥库受到限制,而且没有android文档对此进行解释。我不确定访问KeyStore的替代方案,因为我们的常规应用程序(非即时)对KeyStore有很多依赖,我想不出更好的选择。期待您的建议

2020-12-21 13:07:29.654 28949-28949/com.example.instantappandroidkeystore E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.instantappandroidkeystore, PID: 28949
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.instantappandroidkeystore/com.example.instantappandroidkeystore.MainActivity}: java.lang.NullPointerException: Attempt to invoke interface method 'int android.security.keystore.IKeystoreService.exist(java.lang.String, int)' on a null object reference
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3448)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3595)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2147)
        at android.os.Handler.dispatchMessage(Handler.java:107)
        at android.os.Looper.loop(Looper.java:237)
        at android.app.ActivityThread.main(ActivityThread.java:7814)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1068)
     Caused by: java.lang.NullPointerException: Attempt to invoke interface method 'int android.security.keystore.IKeystoreService.exist(java.lang.String, int)' on a null object reference
        at android.security.KeyStore.contains(KeyStore.java:408)
        at android.security.keystore.AndroidKeyStoreSpi.engineContainsAlias(AndroidKeyStoreSpi.java:1038)
        at java.security.KeyStore.containsAlias(KeyStore.java:1293)
        at androidx.security.crypto.MasterKeys.keyExists(MasterKeys.java:154)
        at androidx.security.crypto.MasterKeys.getOrCreate(MasterKeys.java:96)
        at androidx.security.crypto.MasterKey$Builder.buildOnM(MasterKey.java:357)
        at androidx.security.crypto.MasterKey$Builder.build(MasterKey.java:314)
        at com.example.instantappandroidkeystore.MainActivity.onCreate(MainActivity.kt:32)
        at android.app.Activity.performCreate(Activity.java:7955)
        at android.app.Activity.performCreate(Activity.java:7944)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1307)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3423)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3595) 
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83) 
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) 
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2147) 
        at android.os.Handler.dispatchMessage(Handler.java:107) 
        at android.os.Looper.loop(Looper.java:237) 
        at android.app.ActivityThread.main(ActivityThread.java:7814) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1068)