NoSuchMethodError using commonc codec in Android application(在 Android 应用程序中使用 commonc 编解码器的 NoSuchMethodError)
问题描述
我按照 这里.代码中没有错误.但是当我运行应用程序并调用使用编解码器的函数时,应用程序停止并需要前关闭.
I added the commons codec from apache.org (commons-codec-1.4.jar) in eclipse for my Android application following the instruction here. There is no error in the code. But when I run the application and call the function that use the codec the application stop and need a fore close.
logCat 中说:
Android 运行时:java.lang.NoSuchMethodError:org.apache.commons.codec.binary.Base64.encodeBase64String
Android Runtime: java.lang.NoSuchMethodError: org.apache.commons.codec.binary.Base64.encodeBase64String
代码行是:字符串 tmpStr = Base64.encodeBase64String(msg);//msg 是一个字节[]
the codeline is: String tmpStr = Base64.encodeBase64String(msg); //msg is a byte[]
该应用程序适用于最低 SDK 版本 = 7 (Android 2.1),所以我不能使用 Android Base64
The application is for a min SDK version = 7 (Android 2.1), so I can't use Android Base64
知道如何解决这个问题吗?
Any idea how can I solve the problem?
推荐答案
我遇到了完全相同的问题.所以我开始浏览 android 源代码,事实证明 Don 对 Android 实现 org.apache.commons.code.binary 的猜测是正确的.他对访问它的能力是错误的,你可以,但它是 apache commons 的 1.2 版,而不是 1.4 版甚至 1.5 版.您可以在 android 来源.
I experienced the exact same problem. So i started browsing the android source code, and as it turns out Don's guess about Android having an implementation of org.apache.commons.code.binary is correct. he's wrong about the ability to access it, you can, but its version 1.2 of the apache commons, not version 1.4 or even 1.5. You can see for your self in the android source.
另外请注意,这个问题与这篇文章的重复.
Also as a note, this question is a duplicate of this post.
这篇关于在 Android 应用程序中使用 commonc 编解码器的 NoSuchMethodError的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 Android 应用程序中使用 commonc 编解码器的 NoSuchMethodError


- 将log4j 1.2配置转换为log4j 2配置 2022-01-01
- 从 finally 块返回时 Java 的奇怪行为 2022-01-01
- C++ 和 Java 进程之间的共享内存 2022-01-01
- Spring Boot连接到使用仲裁器运行的MongoDB副本集 2022-01-01
- Java包名称中单词分隔符的约定是什么? 2022-01-01
- Eclipse 插件更新错误日志在哪里? 2022-01-01
- Safepoint+stats 日志,输出 JDK12 中没有 vmop 操作 2022-01-01
- 如何使用WebFilter实现授权头检查 2022-01-01
- Jersey REST 客户端:发布多部分数据 2022-01-01
- value & 是什么意思?0xff 在 Java 中做什么? 2022-01-01