如何获取 sun.misc.BASE64Encoder 类的 JAR 文件?

2022-01-21 00:00:00 base64 android java jar

我的 Activity 类中有一些代码使用 sun.misc.BASE64Encoder 类.但它显示 java.lang.NoClassDefFoundError : sun.misc.BASE64Encoder.我需要 jar 吗?从哪里下载?

I have some code in my Activity class that uses sun.misc.BASE64Encoder class. But it is showing java.lang.NoClassDefFoundError : sun.misc.BASE64Encoder. Do I need the jar? Where can I download it from?

推荐答案

不要使用 sun.* 类.对于 Android 中的 Base64,请使用它的 本机类 或将库添加到您的执行此操作的项目(Apache commons 等).或者,如果您需要在 2.2 之前的设备上使用它,只需将 Android 源代码复制到您的项目(在您自己的包中).

Don't use sun.* classes. For Base64 in Android, use it's native class or add a library to your project that does this (Apache commons, etc.). Alternatively just copy the Android source code to your project (in your own package), if you need to use it on pre-2.2 devices.

相关文章