- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在开发一个应用程序,允许用户通过发送电子邮件与我联系(用户只输入消息,发件人和收件人电子邮件都是我的)。我正在尝试使用 JavaMail API 用 gmail 实现这一点。但是,我在 Transport.send(mimeMessage)
处不断收到此错误。线。
以下是错误消息:
Caused by: java.lang.VerifyError: Rejecting class com.sun.mail.handlers.text_plain that attempts to sub-type erroneous class com.sun.mail.handlers.handler_base (declaration of 'com.sun.mail.handlers.text_plain' appears in /data/app/~~T_TRkO9R_v9j4iEdr4K9Yg==/com.example.compusec-dPeAL8DtGJvU45dJpt8xxA==/base.apk)
Caused by: java.lang.VerifyError: Verifier rejected class com.sun.mail.handlers.handler_base: java.awt.datatransfer.DataFlavor[] com.sun.mail.handlers.handler_base.getTransferDataFlavors() failed to verify: java.awt.datatransfer.DataFlavor[] com.sun.mail.handlers.handler_base.getTransferDataFlavors(): [0x4] can't resolve returned type 'Unresolved Reference: java.awt.datatransfer.DataFlavor[]' or 'Reference: javax.activation.ActivationDataFlavor[]' (declaration of 'com.sun.mail.handlers.handler_base' appears in /data/app/~~T_TRkO9R_v9j4iEdr4K9Yg==/com.example.compusec-dPeAL8DtGJvU45dJpt8xxA==/base.apk)
protected Void doInBackground(Void... voids) {
Properties properties = new Properties();
properties.put("mail.smtp.host", "smtp.gmail.com");
properties.put("mail.smtp.socketFactory.port", "465");
properties.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
properties.put("mail.smtp.auth", "true");
properties.put("mail.smtp.port", "465");
session = javax.mail.Session.getInstance(properties, new javax.mail.Authenticator(){
protected PasswordAuthentication getPasswordAuthentication(){
return new PasswordAuthentication("sender@gmail.com","senderpass");
}
});
session.setDebug(true);
MimeMessage mimeMessage = new MimeMessage(session);
try {
mimeMessage.setFrom(new InternetAddress("sender@gmail.com"));
mimeMessage.addRecipients(Message.RecipientType.TO, String.valueOf(new InternetAddress(email)));
mimeMessage.setSubject(subject);
mimeMessage.setText(message);
Transport.send(mimeMessage);
} catch (MessagingException e) {
e.printStackTrace();
}
return null;
}
plugins {
id 'com.android.application'
}
android {
compileSdkVersion 30
buildToolsVersion "30.0.2"
packagingOptions {
pickFirst 'META-INF/LICENSE.txt' // picks the JavaMail license file
}
defaultConfig {
applicationId "com.example.myapplication"
minSdkVersion 23
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
repositories {
jcenter()
maven {
url "https://maven.java.net/content/groups/public/"
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'com.google.android.material:material:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
compile 'com.sun.mail:android-mail:1.6.2'
compile 'com.sun.mail:android-activation:1.6.2'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
最佳答案
在 build.gradle
中使用它:
android {
...
packagingOptions {
exclude 'META-INF/NOTICE.md'
exclude 'META-INF/LICENSE.md'
}
}
dependencies {
implementation 'com.sun.mail:android-mail:1.6.6'
implementation 'com.sun.mail:android-activation:1.6.6'
...
}
归功于对
this 的最后几条评论问题
关于java - Android Studio VerifyError 拒绝来自 JavaMail API 的类 text_plain,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64650611/
我有一个Gradle 4.4.1脚本,偶尔会失败。这通常在运行test任务之前在多台计算机上发生。 这是相关的日志(在运行gradlew test --info时获取): Up-to-date che
我正在使用“打开模块设置 > 新建 > 导入 .JAR/.AAR 包”向我的项目(.aar)添加一个库。 它在应用程序打开时正确构建,但是当实例化该库的第一个类时,它给我提供了该类的“Java.lan
我在 J2EE 容器中偶尔收到以下错误。有时容器会启动,没有任何问题,有时容器不会启动,因为这个错误,以前有人见过这个错误吗...?可能是什么原因..?它是否涉及任何类加载器/安全问题..? java
我正在为 2.2 (minSdkVersion=8) 开发,突然出现这个错误: arbitrarily rejecting large method (regs=75 count=28584) rej
我在我的应用程序中使用指纹传感器。我知道 api 可用于 marshmallow 及以上操作系统。因此,在我的类里面运行时,我正在动态检查 sdk 版本。 即使指纹代码不执行,我在 4.0 andro
ERROR [org.springframework.web.context.ContextLoader:313] - Context initialization failed java.lang.
我正在使用Hadoop的Java项目中工作,并且有一个java.lang.VerifyError,我不知道如何解决它。我看到有人遇到相同类型的问题,但没有答案,或者解决方案在我的情况下不起作用。 我的
我正在扩展 JFreeChart ChartComposite 类。当我尝试创建扩展类的实例时,我收到 java.lang.VerifyError : .... 函数调用的不兼容对象参数 错误。 最佳
我使用 jcifs-1.3.17 库来检查共享文件夹上的一些文件。一周前,我发现我的代码无法正常工作。我遇到 500 服务器错误,如下所示: (类:jcifs/smb/NtlmPasswordAuth
有时我可以在崩溃报告服务日志中找到如下所示 Caused by: java.lang.VerifyError: com/google/android/gms/auth/GoogleAuthUtil
我正在开展一个项目,我们希望在该项目中重用近期类似项目的代码。然而,这一次,我们希望将代码拆分到三个库中,以便在未来的项目中更容易使用,我们也将在这些项目中重复使用这些代码。 我将像在 Netbean
我正在将我的appengine-项目从ant构建迁移到maven,我使用带有JDO 2的java 8和maven-datanucleus插件来进行类增强和maven appengine-plugin
提前道歉,但我以前从未见过这个错误,也不知道该包含什么。我正在使用 NetBeans 并突然开始出现此错误: Exception in thread "AWT-EventQueue-0" java.l
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 要求我们推荐或查找工具、库或最喜欢的场外资源的问题对于 Stack Overflow 来说是偏离主题的,
我有一个应用程序,它使用 overridePendingTransition 在从一个 Activity 转换到另一个 Activity 时执行一些自定义动画。这在 Android 2.0 中可用,但
目前正在经历一场试图修复 java.lang.verifyerror 的噩梦,遇到了 eclipse 问题,所以我决定卸载并重新安装它,一切似乎都很正常,直到我尝试启动该应用程序,那时我注意到我无法启
我最近开始为我自己的语言编写一个编译器,但是当我调用 main 方法时它开始抛出异常。它适用于我的其他测试类,但它不想使用这个。据我所知,在此类和其他类之间调用方法的方式没有任何不同。这是异常(exc
我正在开发一个 Android 项目,该项目使用我正在创建的单独 JAR 文件中的类和方法,问题出在一个名为 XpathUtil 的特定实用程序类,该类抛出一个 VerifyError 每次我尝试调用
public class Config { public static Ref s = new Ref(new Config()); static class Ref {
在编写一些 Java 代码时,我遇到了一个我无法识别的异常,即 java.lang.VerifyError。一些谷歌搜索表明这通常是一个 jvm/javac 错误,我很好奇我的情况是否如此。 我怀疑的
我是一名优秀的程序员,十分优秀!