jakartaee / mail-api

Jakarta Mail Specification project
https://jakartaee.github.io/mail-api
Other
244 stars 101 forks source link

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

Closed erictamhk closed 7 months ago

erictamhk commented 1 year ago

Describe the bug when using android 7, API 23, got this error

dependencies implementation 'org.eclipse.angus:jakarta.mail:2.0.1' implementation 'org.eclipse.angus:angus-activation:2.0.1' implementation 'jakarta.activation:jakarta.activation-api:2.1.2'

Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Ljava/util/Base64; at org.eclipse.angus.mail.smtp.SMTPTransport$LoginAuthenticator.doAuth(SMTPTransport.java:1010) at org.eclipse.angus.mail.smtp.SMTPTransport$Authenticator.authenticate(SMTPTransport.java:955) at org.eclipse.angus.mail.smtp.SMTPTransport.authenticate(SMTPTransport.java:889) at org.eclipse.angus.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:793)

jmehrens commented 1 year ago

The version of Android meets requirements per https://eclipse-ee4j.github.io/angus-mail/Android

Angus Mail for Android requires at least Android API level 19, which corresponds to Android KitKat, currently the oldest supported version of Android.

Per the Base64 API this class was added in JDK 8.

However, per https://developer.android.com/reference/java/util/Base64:

Added in API level 26 Base64

For JakartaMail, I think we'll need to review what the minimum version of Android should be supported. If we require API 26 then this ticket will just be closed. Looking at https://github.com/jakartaee/mail-api/pull/554 it seems that this ticket should be closed and a new linked ticket should be created to update the documentation.

For AngusMail, I think we could look at switching to use MimeUtility.encode with ByteArrayOutputStream or BASE64EncoderStream.encode(user.getBytes(StandardCharsets.UTF_8)) to replace the use of Base64. If I recall correctly there are some differences in how some characters are handled.

jmehrens commented 8 months ago

Per Meet Google Play's target API level requirement:

Starting on August 31, 2023:

New apps must target Android 13 (API level 33) or higher; except for Wear OS apps, which must target a version between Android 11 (API level 30) and Android 13 (API level 33), inclusive.

App updates must target Android 13 or higher and adjust for behavioral changes in Android 13; except for Wear OS apps, which must target Android 11.

Permanently private apps—which are restricted to users in a specific organization and are intended for internal distribution only—aren't required to meet the target API level requirements.

[snip]

...Furthermore, as of Android 10 (API level 29), users see a warning when they start an app for the first time if the app targets Android 5.1 (API level 22) or lower.

Per Which Java APIs can I use in my Java or Kotlin source code? the API level 32 and API level 33 are versions that support Java 11 source syntax. API level 34 supports Java 17 source syntax.

Per Jakarta EE Platform 10:

Minimum Java SE Version Java SE 11 or higher

The Android API Levels site shows the usage of devices.

Given that information we should close this ticket as will not fix and create new ticket to move the minimum API version for JakartaMail and Angus Mail to API 33 as that would allow us to stop building for JDK 8. Moving to that API version 26 or greater will give access to java.lang.invoke, java.util.Base64, and java.time. If we want to still target JDK 8 then we should require API version 26.

@lukasj What are your thoughts?

lukasj commented 8 months ago

@jmehrens I'm for jumping to API 33+/SE 11 as a base

jmehrens commented 7 months ago

Closed as won't fix because Android 7, API 23 is no longer supported. This issue has been superseded by: https://github.com/jakartaee/mail-api/issues/709