私はアンドロイドアプリを開発しています。残念ながら、互換性の問題があります。ソース コードはファームウェア 4.1 で動作しますが、ファームウェア 2.2 のデバイスではクラッシュします。エラーは、ObjectInputStream によって引き起こされた「ClassNotFoundException」のようです。
暗号化と復号化のための私のソースコード:
private Key getPublicKey() {
    try {
        InputStream fis = activity.getResources().openRawResource(R.raw.publick);
        ObjectInputStream ois = new ObjectInputStream(fis);
        Key RSApublicKey = (Key) ois.readObject();
        return RSApublicKey;
    }
    catch (FileNotFoundException e) {
        e.printStackTrace();
    }
    catch (IOException e) {
        e.printStackTrace();
    }
    catch (ClassNotFoundException e) {
        e.printStackTrace();
    }
    return null;
}
private Key getPrivateKey() {
    try {
        InputStream fis = activity.getResources().openRawResource(R.raw.privatek);
        ObjectInputStream ois = new ObjectInputStream(fis);
        Key RSAprivateKey = (Key) ois.readObject();
        return RSAprivateKey;
    }
    catch (FileNotFoundException e) {
        e.printStackTrace();
    }
    catch (IOException e) {
        e.printStackTrace();
    }
    catch (ClassNotFoundException e) {
        Log.e("error", "Error: " + e);
        e.printStackTrace();
    }
    return null;
}
public byte[] encrypt(String data) {
    byte[] encrypted = null;
    try {
        Cipher cipher = Cipher.getInstance("RSA");
        cipher.init(Cipher.ENCRYPT_MODE, getPublicKey());
        encrypted = cipher.doFinal(data.getBytes());
    }
    catch (IllegalBlockSizeException e) {
            e.printStackTrace();
    }
    catch (BadPaddingException e) {
        e.printStackTrace();
    }
    catch (InvalidKeyException e) {
        e.printStackTrace();
    }
    catch (NoSuchAlgorithmException e) {
        e.printStackTrace();
    }
    catch (NoSuchPaddingException e) {
        e.printStackTrace();
    }
    catch (NoSuchProviderException e) {
        e.printStackTrace();
    }
    return encrypted;
}
public String decrypt(byte[] encrypted) {
    byte[] decrypted = null;
    try {
        Cipher cipher;
        cipher = Cipher.getInstance("RSA");
        cipher.init(Cipher.DECRYPT_MODE, getPrivateKey());
        decrypted = cipher.doFinal(encrypted);
    }
    catch (NoSuchAlgorithmException e) {
        e.printStackTrace();
    }
    catch (NoSuchPaddingException e) {
        e.printStackTrace();
    }
    catch (InvalidKeyException e) {
        e.printStackTrace();
    }
    catch (IllegalBlockSizeException e) {
        e.printStackTrace();
    }
    catch (BadPaddingException e) {
        e.printStackTrace();
    }
    catch (NoSuchProviderException e) {
        e.printStackTrace();
    }
    return new String(decrypted);
}
logcat のエラー:
03-23 10:13:19.706: E/Error(427): Error: java.lang.ClassNotFoundException: com.android.org.bouncycastle.jce.provider.JCERSAPrivateCrtKey
どうすればAndroid 2.2で動作させることができますか?