小编Moh*_*ari的帖子

Android keystore2.AndroidKeyStoreProvider 在 API 31 的三星设备上引发 NPE

从昨天起,我收到了运行 Android 12 的三星设备上的大量崩溃报告。AndroidKeyStoreProvider 在调用 X509Certificate.getPublicKey() 时抛出 NPE。它在其他品牌的设备上运行良好。

密钥对生成方法:

   public void generateKeys(Context context) throws GeneratePairKeyException {
    KeyPairGenerator keyPairGenerator;
    try {
        if(KeyStoreUtil.getPrivateKey() == null){
            Calendar start = GregorianCalendar.getInstance();
            Calendar end = GregorianCalendar.getInstance();
            end.add(Calendar.YEAR, 10);
            keyPairGenerator = KeyPairGenerator.getInstance("RSA", ANDROID_KEY_STORE);
            keyPairGenerator.initialize(new KeyPairGeneratorSpec.Builder(context)
                    .setAlias(ALIAS)
                    .setSerialNumber(BigInteger.valueOf(1))
                    .setStartDate(start.getTime())
                    .setEndDate(end.getTime())
                    .setSubject(new X500Principal("CN=Pushe_CA"))
                    .build());
            keyPairGenerator.generateKeyPair();
        }
    } catch (NoSuchAlgorithmException |
            NoSuchProviderException | InvalidAlgorithmParameterException e) {
        Logger.e(e);
        throw new GeneratePairKeyException("pair key not created");
    } catch (IllegalStateException e) {
        throw e;
    } catch (Exception e) {
        throw new GeneratePairKeyException("pair key …
Run Code Online (Sandbox Code Playgroud)

android x509certificate key-pair android-keystore

5
推荐指数
0
解决办法
327
查看次数

将 android studio 更新为 Chipmunk 后导航组件方向生成的类中的构建时间错误

在导航组件生成的所有“方向”类中将 android studio 更新为花栗鼠版本后,我收到“未解析的参考:R”构建时间错误。R 类未在该类中导入,尽管我可以手动导入它,但类将重新生成,而无需在下一个构建中导入

android gradle 插件版本 = 7.2.0

gradle 包装版本 = 7.3.3-all

有什么解决办法吗?

android android-studio android-gradle-plugin android-studio-chipmunk

5
推荐指数
1
解决办法
746
查看次数