错误记录:Android 11 发送邮件报错
问题出现:
ClassNotFound
解决方法 :
不使用下载的JavaMail包,在build.gradle文件中添加以下语句
implementation 'com.sun.mail:android-mail:1.6.7'
implementation 'com.sun.mail:android-activation:1.6.7'
//这段在android{}中添加
packagingOptions {
pickFirst 'META-INF/LICENSE.md' // picks the JavaMail license file
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE.md'
exclude 'META-INF/notice.txt'
exclude 'META-INF/ASL2.0'
exclude("META-INF/*.kotlin_module")
}
经过测试,JavaMail1.5.5版本在Android 11,Android 12版本无法正常使用,但在Android 13版本可以正常使用。