Apache的共享codeC与Android:找不到方法 [英] Apache Commons Codec with Android: could not find method

查看:904
本文介绍了Apache的共享codeC与Android:找不到方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

今天,我想包括apache.commons。codeC包在我的Andr​​oid应用程序,并能得到它运行并非如此。安卓找不到方法ord.apache.commons。codec.binary。*和输出DDMS以下错误

Today I tried including the apache.commons.codec package in my Android application and couldn't get it running. Android could not find method ord.apache.commons.codec.binary.* and output the following errors in DDMS

八月1日至12日:41:48.161:ERROR / dalvikvm(457):找不到方法org.apache.commons codec.binary.Base64.en codeBase64URLSafeString,从方法com.dqminh引用。 .app.util.Util.sendRequest

01-12 08:41:48.161: ERROR/dalvikvm(457): Could not find method org.apache.commons.codec.binary.Base64.encodeBase64URLSafeString, referenced from method com.dqminh.app.util.Util.sendRequest

八月1日至12日:41:48.161:WARN / dalvikvm(457):VFY:无法解析静态方法10146:Lorg /阿帕奇/公/ codeC /二/ Base64的; .EN codeBase64URLSafeString( [B)Ljava /朗/字符串;

01-12 08:41:48.161: WARN/dalvikvm(457): VFY: unable to resolve static method 10146: Lorg/apache/commons/codec/binary/Base64;.encodeBase64URLSafeString ([B)Ljava/lang/String;

八月1日至12日:41:48.161:WARN / dalvikvm(457):VFY:拒绝运code 0x71在×0004

01-12 08:41:48.161: WARN/dalvikvm(457): VFY: rejecting opcode 0x71 at 0x0004

在如何解决这个问题的任何线索?非常感谢。

Any clue on how to solve this problem ? Thanks a lot.

推荐答案

我也有类似的问题,同时采用了android与的OAuth库我发展。

I had a similar problem while using android with an OAuth library I'm developing.

我也从机器人得到了,虽然我已经包括 apache.commons,在类路径中codeC ,一个特定的方法(恩codeBase64String )未找到。

I also got from android that, although I had included apache.commons.codec in the classpath, a particular method (encodeBase64String) was not found.

检查的javadoc,这两种方法声称自己是 1.4,仅大,所以我的猜测是,机器人已经包括公地的旧版本。codeC 其中,这些方法的确是不确定的。

Checking the javadocs, both methods claim to be 1.4 and greater only, so my guess is that android already includes an older version of commons.codec where these methods are indeed undefined.

我的解决办法是使用旧的方法,像这样的:

My solution was to use an older method, like this:

String encodedString = new String(Base64.encodeBase64('string to encode'));

您要使用的方法是不同的,因为它取代+和/ url的安全值 - 和_。所以,你可能会使用这样的:

The method you want to use is different since it replaces + and / with url-safe values - and _. So you probably might use something like:

String encodedString = new String(Base64.encodeBase64('string to encode'));
String safeString = encodedString.replace('+','-').replace('/','_');

希望帮助!

这篇关于Apache的共享codeC与Android:找不到方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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