的NoSuchMethodError使用commonc codeC在Android应用程序应用程序、commonc、NoSuchMethodError、Android

2023-09-14 23:03:23 作者:你是我忘不掉的伤

我添加了公共$ C $从apache.org在Eclipse CC(commons- codeC-1.4.jar)为我的Andr​​oid应用程序下面的指令here.有一个在code没有错误。但是,当我运行的应用程序,并调用使用codeC的应用程序停机,需要一个前关闭该功能。

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.en codeBase64String

Android Runtime: java.lang.NoSuchMethodError: org.apache.commons.codec.binary.Base64.encodeBase64String

在$ C $克莱因是:     字符串tmpStr = Base64.en codeBase64String(MSG); // msg是一个byte []

the codeline is: String tmpStr = Base64.encodeBase64String(msg); //msg is a byte[]

该应用程序是一个最小的SDK版本= 7(Android 2.1的),所以我不能使用安卓的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源$ C ​​$ C,并作为原来唐的猜测大约有org.apache.commons的实现机器人。code.binary是正确的。他错了即将访问的能力,你可以,但Apache的百科全书,其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.