Is there a Base64 library that is compatible with both Android and Java(是否有同时兼容 Android 和 Java 的 Base64 库)
问题描述
我有一个用于 Java 和 Android 项目的通用库,它需要一个 base64 编码器/解码器.问题是,Apache commons 库不适用于 Android,至少我无法成功实现 - 由于 Android 已经实现和早期版本,因此每当我尝试编码或解码时都会在运行时导致错误:
I have a common library that I use for both Java and Android projects and it requires a base64 encoder/decoder. The trouble is, the Apache commons library does not work with Android, at least not that I have been able to successfully implement - due to Android already implementing and earlier version and thus causing an error at run time whenever I attempt to encode or decode:
Base64.decodeBase64
返回错误:
AndroidRuntime(1420): java.lang.NoSuchMethodError: org.apache.commons.codec.binary.Base64.decodeBase64
如果有人知道与 Java 和 Android 兼容的 base64 库,或者可以向我解释如何解决 Apache commons 问题,我将不胜感激.:^)
If anyone knows of a base64 library that is compatible with both Java and Android, or can explain to me how to get around the Apache commons issue, I would be very grateful. :^)
推荐答案
只有base64".它是如此微不足道,您可以搜索任何java base64"并使用任何实现.
There's just "base64". It so trivial that you can google for any "java base64" and use any implementation.
编辑
如果您以 API8 之前为目标,只需从 API8 中获取 Base64 实现的源代码(它是 android/util/Base64.java) 并复制到你的项目中.
If you target pre API8, simply grab the source from Base64 implementation from API8 (it is android/util/Base64.java) and copy into your project.
这篇关于是否有同时兼容 Android 和 Java 的 Base64 库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:是否有同时兼容 Android 和 Java 的 Base64 库
基础教程推荐
- 使用堆栈算法进行括号/括号匹配 2022-01-01
- Struts2 URL 无法访问 2022-01-01
- 如何对 Java Hashmap 中的值求和 2022-01-01
- 无法复制:“比较方法违反了它的一般约定!" 2022-01-01
- Spring AOP错误无法懒惰地为此建议构建thisJoinPoin 2022-09-13
- 存储 20 位数字的数据类型 2022-01-01
- REST Web 服务返回 415 - 不支持的媒体类型 2022-01-01
- RabbitMQ:消息保持“未确认"; 2022-01-01
- 修改 void 函数的输入参数,然后读取 2022-01-01
- 问题http://apache.org/xml/features/xinclude测试日志4j 2 2022-01-01
