Jar mismatch! Fix your dependencies

本文介绍了在Android项目开发中遇到的Jar包冲突问题——“Jarmismatch!Fixyourdependencies”。该错误通常由不同版本的android-support-v4.jar引起。文章提供了解决方案:删除所有冲突的Jar包并替换为最新版本。

   

          在开发Android项目的时候,有时需要引用多个项目作为library。在引用项目的时候,有时会出现“Jar mismatch! Fix your dependencies”错误。

这是因为两个项目的jar包(android-support-v4.jar)不一致。

          解决方法是把2个jar都删除,然后各自加上最新的jar包。





这样2个jar 包就一致了。


转:http://blog.youkuaiyun.com/android_shrimp/article/details/8477416

“Decryption failed: Tag mismatch!” 错误通常意味着解密过程中的认证标签不匹配,即加密和解密时使用的某些参数不一致。以下是可能的解决办法: #### 检查 API v3 密钥 确保使用的是当前商户号对应的正确 API v3 密钥,避免使用其他商户号的密钥,或者使用了 APIv2 的 APIKey。可仔细核对密钥的长度、字符范围等是否符合官方文档要求,不同的 API 对密钥的格式和长度有不同规定,若不符合要求,密钥可能错误。若对密钥的正确性存在疑问,可以联系 API 提供商的官方支持团队,提供相关信息,让他们协助确认密钥的正确性。 #### 检查加密参数 在 AES/GCM 加密模式中,认证标签依赖于初始化向量(IV)、关联数据(AAD)和密钥。确保在加密和解密过程中使用相同的 IV 和 AAD。若在代码中创建新的 IV 数组,可能导致加密和解密时的 IV 值不同,从而使认证失败。以下是检查 IV 和 AAD 的示例代码: ```java import javax.crypto.Cipher; import javax.crypto.KeyGenerator; import javax.crypto.SecretKey; import javax.crypto.spec.GCMParameterSpec; import java.nio.charset.StandardCharsets; import java.security.SecureRandom; import java.util.Base64; public class APIV3KeyDecryptionTest { private static final int GCM_TAG_LENGTH = 128; private static final int GCM_IV_LENGTH = 12; public static String decrypt(String ciphertext, String key, byte[] associatedData, byte[] nonce) throws Exception { Cipher cipher = Cipher.getInstance("AES/GCM/NoPadding"); SecretKey secretKey = new javax.crypto.spec.SecretKeySpec(key.getBytes(StandardCharsets.UTF_8), "AES"); GCMParameterSpec spec = new GCMParameterSpec(GCM_TAG_LENGTH, nonce); cipher.init(Cipher.DECRYPT_MODE, secretKey, spec); cipher.updateAAD(associatedData); byte[] decodedCiphertext = Base64.getDecoder().decode(ciphertext); byte[] decryptedBytes = cipher.doFinal(decodedCiphertext); return new String(decryptedBytes, StandardCharsets.UTF_8); } public static void main(String[] args) { try { String ciphertext = "your_ciphertext_here"; String apiV3Key = "your_api_v3_key_here"; // 确保 associatedData 和 nonce 在加密和解密时相同 byte[] associatedData = "associated_data".getBytes(StandardCharsets.UTF_8); byte[] nonce = new byte[GCM_IV_LENGTH]; // 这里需要确保 nonce 是加密时使用的 nonce SecureRandom random = new SecureRandom(); random.nextBytes(nonce); String decryptedText = decrypt(ciphertext, apiV3Key, associatedData, nonce); System.out.println("Decrypted text: " + decryptedText); } catch (Exception e) { System.err.println("Decryption failed: " + e.getMessage()); } } } ``` #### 检查 SecureRandom 实现 在 Linux 环境下,SecureRandom 实现可能依赖于操作系统本身的内部状态,可能导致解密失败。解决方法是在调用 `getInstance` 方法之后再调用一次 `setSeed` 方法 [^4]。 ```java import java.security.SecureRandom; SecureRandom secureRandom = SecureRandom.getInstance("SHA1PRNG"); secureRandom.setSeed(System.currentTimeMillis()); ```
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值