Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
946 views
in Technique[技术] by (71.8m points)

android - java.lang.ClassNotFoundException: Didn't find class "java.util.Base64"

Using third party JAVA jar file for Android application, it has dependency on 'java.util.Base64'. So here I can not use 'android.util.Base64'.

While running the app I am getting the below exception:

java.lang.ClassNotFoundException: Didn't find class "java.util.Base64"

As per some of the stack overflow solution, we should add this dependency in android gradle

implementation "commons-codec:commons-codec:1.10"

But still the app is crashing with same exception.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

https://developer.android.com/reference/java/util/Base64 says Base64 is "Added in API level 26". So if your phone is older than Android 8.0 Oreo, Android won't be able to find that class.

If you want to use the Base64 class from Apache commons (the commons-codec import you listed), make sure you import org.apache.commons.codec.binary.Base64 instead. Note the API for those two classes are not exactly the same.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...