I just updated my Android Studio to version 3.1 and I was surprised with an unknown error message: Program type already present: com.sun.activation.registries.LineTokenizer
> :testeapn:transformClassesWithDexBuilderForDebug AGPBI:
> {"kind":"error","text":"Program type already present: com.sun.activation.registries.LineTokenizer","sources":[{}],"tool":"D8"}
> :testeapn:transformDexArchiveWithExternalLibsDexMergerForDebug FAILED
>
> FAILURE: Build failed with an exception.
>
> * What went wrong: Execution failed for task ':testeapn:transformDexArchiveWithExternalLibsDexMergerForDebug'.
After digging a lot I realized the problems was the javax.mail library. So, after remove every .jar and every mentions to that library and I could build again, but I removed this feature of my app.
Now I have to make my app to send mails again, but I can't find how to do this and I'm asking you for a help.
I google a lot and found in https://javaee.github.io/javamail/Android new information (for me, at least): we should not add the additionnal.jar, mail.jar and activation.jar anymore. We must add new dependencies:
implementation 'com.sun.mail:android-mail:1.6.1' implementation 'com.sun.mail:android-activation:1.6.1'
But, after add those lines in my app.gradle and without write a line of code, I got the above error again.
Do someone know what this message means and what to do?
I had exactly the same problem as you after upgrading from the 3 jars (additionnal.jar
, mail.jar
and activation.jar
) to com.sun.mail:android-mail:1.6.1
and com.sun.mail:android-activation:1.6.1
. I am also using Android Studio 3.1.
My solution is, instead of using 1.6.1, using the a little bit older version 1.6.0. The error is gone and the app builds and works again.
implementation 'com.sun.mail:android-mail:1.6.0' implementation 'com.sun.mail:android-activation:1.6.0'
Some details
I did a little digging there. It seems the problem is that com.sun.mail:android-activation:1.6.1
has a dependency on javax.activation:activation:1.1
, and both these packages contain com.sun.activation.registries.*
classes. It caused the build to fail.
On the contrary, the dependency wasn't there in com.sun.mail:android-activation:1.6.0
.
The dependency graph is generated by running gradlew :app:dependencies --configuration debugRuntimeClasspath
.
1.6.0
debugRuntimeClasspath - Resolved configuration for runtime for variant: debug +--- com.sun.mail:android-mail:1.6.1 | +--- com.sun.mail:android-activation:1.6.1 | | \--- javax.activation:activation:1.1 | \--- javax.activation:activation:1.1 +--- com.sun.mail:android-activation:1.6.1 (*) +---
1.6.0
debugRuntimeClasspath - Resolved configuration for runtime for variant: debug +--- com.sun.mail:android-mail:1.6.0 | \--- com.sun.mail:android-activation:1.6.0 +--- com.sun.mail:android-activation:1.6.0
You can see it in the following screen shot too.
Android Studio screen shot when using version 1.6.1
Though I would like to issue a bug report to their developers. Their old Issue Tracker page (https://github.com/javaee/javamail/issues) is closed, and their new project page on Eclipse Foundation (https://projects.eclipse.org/projects/ee4j.javamail) is extremely slow that I can barely open it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With