1

I'm trying to send an e-mail like in this post: Sending Email in Android using JavaMail API without using the default/built-in app

And adding in my build.gradle and app file this lines: https://javaee.github.io/javamail/Android

Error:

Error:Execution failed for task ':app:transformClassesWithDexForDebug'. > com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexException: Multiple dex files define Lcom/sun/activation/registries/LineTokenizer;

But with the following app file I have a execution failed and don't know why.

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "26.0.0"
    defaultConfig {
        applicationId "com.github.ocaparrostortosa.MyApplication"
        minSdkVersion 21
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    packagingOptions {
        pickFirst 'META-INF/LICENSE.txt' // picks the JavaMail license file
    }
}

dependencies {
    compile 'com.sun.mail:android-mail:1.5.5'
    compile 'com.sun.mail:android-activation:1.5.5'
    compile 'com.google.firebase:firebase-core:10.2.1'
    compile 'com.google.firebase:firebase-database:10.2.1'
    compile 'com.google.firebase:firebase-auth:10.2.1'
    compile 'com.google.android.gms:play-services-auth:10.2.1'
    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:25.3.1'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'

And this one is my Project gradle:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.2'
        classpath 'com.google.gms:google-services:3.0.0'
    }
}

allprojects {
    repositories {
        jcenter()
        maven {
            url "https://maven.java.net/content/groups/public/"
        }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

Can someone help me please? I'm close to finish the project :D

P.D: Sorry for my English and for the presentation, I'm new in stackoverflow.

1 Answers1

2

this error is quite tricky. i also had a hard time on this. I solve my problem somehow by adding this multiDexEnabled true on my gradle build.config

android {
     defaultConfig {
         minSdkVersion 14 x
         targetSdkVersion 23
         multiDexEnabled true
     }
}

dependencies {
    compile 'com.android.support:multidex:1.0.1'
}

Take note, this solution is case to case basis. One scenario is - my app was very large that it exceeds 64MB limit. If this does not work, check your dependencies.

Other scenario was caused by Google Maps API dependencies that the version needs to be inline with the APP target SDK.

Rashid
  • 1,700
  • 1
  • 23
  • 56