title: Android Studio VerifyError rejecting class text_plain from JavaMail API
body: <p>I'm developing an application that allows the user to contact me by sending an email (the user only inputs the message, sender and receiver emails are both mine). I'm trying to implement this with gmail using the JavaMail API. However, I keep getting this error at the <code>Transport.send(mimeMessage)</code> line.</p>
  <p>Here are the error messages:</p>
  <blockquote>
  <p>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)</p>
  <p>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)</p>
  </blockquote>
  <p>Here is my code:</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>    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;
      }</code></pre>
  </div>
  </div>
  </p>
  <p>And the gradle script:</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>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'
  }</code></pre>
  </div>
  </div>
  </p>