在 Android 应用程序中使用 commonc 编解码器的 NoSuchMethodError [英] NoSuchMethodError using commonc codec in Android application

查看:32
本文介绍了在 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆