Mapbox-navigation-android: Android 4.1.2 - Error With Dependencies

Created on 26 Sep 2017  路  4Comments  路  Source: mapbox/mapbox-navigation-android

Since Adding The Below Dependency I Have The Following Error.

Dependency
compile 'com.mapbox.mapboxsdk:mapbox-android-plugin-locationlayer:0.1.0'

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 Landroid/arch/core/internal/SafeIterableMap;

Below Is My Full Gradle File.

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    buildToolsVersion "26.0.1"
    defaultConfig {
        applicationId "uk.co.ainscough.routeinfo"
        minSdkVersion 15
        targetSdkVersion 26
        versionCode 2
        versionName "2.0.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

repositories {
    mavenCentral()
    maven { url "http://oss.sonatype.org/content/repositories/snapshots/" }
    maven { url 'https://maven.google.com' }
}

dependencies {
    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 files('libs/xstream-1.4.7.jar')

    // Mapbox Maps SDK
    compile('com.mapbox.mapboxsdk:mapbox-android-sdk:5.1.3@aar') {
        transitive=true
        exclude module: 'lost'
        exclude module: 'mapbox-java-geojson'
        exclude module: 'mapbox-android-telemetry'
    }
    compile 'com.mapbox.mapboxsdk:mapbox-android-navigation:0.6.0'
    compile 'com.mapbox.mapboxsdk:mapbox-android-navigation-ui:0.7.0-SNAPSHOT@aar'
    compile 'com.mapbox.mapboxsdk:mapbox-android-plugin-locationlayer:0.1.0'
    compile 'com.android.support:cardview-v7:26.+'
    compile 'com.android.support:appcompat-v7:26.+'
    compile 'com.android.support:design:26.+'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.android.support:support-v4:26.+'

    compile 'com.google.android.gms:play-services-maps:11.0.4'
    compile 'junit:junit:4.12'

    compile 'com.jakewharton:butterknife:8.6.0'
    compile 'com.jakewharton:butterknife-compiler:8.6.0'

}

Most helpful comment

I know this is closed but I don't think the issue is the 64k limit - it's because the multidex merge fails because the appcompat-v7 library includes the android.arch.core:common:1.0.0 library and com.mapbox.mapboxsdk:mapbox-android-plugin-locationlayer:0.1.0 includes android.arch.core:core:1.0.0-alpha3.

I was able to get my project to build again once I added this:

implementation ('com.mapbox.mapboxsdk:mapbox-android-plugin-locationlayer:0.1.0') {
        exclude group: 'android.arch.core'
    }

As far as I can tell the locationlayer is still working.

All 4 comments

Multiple dex files define

You're hitting the 64k method limit in Android. Checkout this doc on how to get around it. There's also a few issues with your dependencies which you might want to resolve.

I know this is closed but I don't think the issue is the 64k limit - it's because the multidex merge fails because the appcompat-v7 library includes the android.arch.core:common:1.0.0 library and com.mapbox.mapboxsdk:mapbox-android-plugin-locationlayer:0.1.0 includes android.arch.core:core:1.0.0-alpha3.

I was able to get my project to build again once I added this:

implementation ('com.mapbox.mapboxsdk:mapbox-android-plugin-locationlayer:0.1.0') {
        exclude group: 'android.arch.core'
    }

As far as I can tell the locationlayer is still working.

I just ran into the same error using mapbox-android-navigation:0.6.2, and koocbor's fix works for the navigation SDK as well.

implementation ('com.mapbox.mapboxsdk:mapbox-android-navigation:0.6.2') {
     exclude group: 'android.arch.core' 
}

The mapbox-android-navigation library shouldn't depend on an alpha or beta version since that interfere's with gradle's automatic version reconciliation. Should I open a new Issue or will someone see this?

@eric-hartwell fwiw 0.7.0 was released with the latest stable versions

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hmkum picture hmkum  路  4Comments

karussell picture karussell  路  4Comments

skienzl picture skienzl  路  5Comments

jethromay picture jethromay  路  7Comments

riastrad picture riastrad  路  3Comments