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 库


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