question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Building library failed with dex errors

See original GitHub issue

Description

Sync’d gradle, that went OK. Clean Project, that went OK. Then added Rebuild or run on device and it fails with:

Error:com.android.builder.dexing.DexArchiveBuilderException: Failed to process /Users/andres/.gradle/caches/transforms-1/files-1.1/leku-4.0.1.aar/349173a406929f5032ad2ef1e18bc511/jars/classes.jar
Error:com.android.builder.dexing.DexArchiveBuilderException: Error while dexing com/schibstedspain/leku/geocoder/AndroidGeocoderDataSource.class
Error:com.android.dx.cf.code.SimException: invalid opcode ba (invokedynamic requires --min-sdk-version >= 26)
Error:Execution failed for task ':app:transformClassesWithDexBuilderForDebug'.
> com.android.build.api.transform.TransformException: com.android.builder.dexing.DexArchiveBuilderException: com.android.builder.dexing.DexArchiveBuilderException: Failed to process /Users/andres/.gradle/caches/transforms-1/files-1.1/leku-4.0.1.aar/349173a406929f5032ad2ef1e18bc511/jars/classes.jar

This issue is more for me as well to track my progress debugging this. I have a feeling that my machine might be the problem. So, I’m transferring my project to a new one just in case. Until then I’ll keep this updated here:

I tried adding minsdk to 26 and it did build but I can’t test it because I don’t have a 26 device. Originally I was loading the full google play services bundle as an implementation but then I got multidex and too many methods (dex) errors and reduced it just to maps and places/locations, that reduced my original 30+ errors to just the four above. Removing the leku library and instances, it builds just fine without errors or warnings. Attached is my app gradle file:

Info Required

  • Which version of the library do you actually use? 4.0.1

  • Do you have the localization permission granted?

  • Are you sending parameters to the activity through the bundle? N/A

  • Could you describe what are the actions do you make to raise that error? Building

  • Android monitor shows any log related to the library when the error is shown? N/A

  • Any other thing that could help me to reproduce the error?

Screenshots

apply plugin: 'com.android.application'
apply plugin: 'realm-android'
repositories {
    jcenter()

}

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "com.example.com"
        minSdkVersion 24
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        externalNativeBuild {
            cmake {
                cppFlags "-std=c++11"
            }
        }

    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    externalNativeBuild {
        cmake {
            path "CMakeLists.txt"
        }
    }
}

dependencies {
    //implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation 'com.android.support:support-annotations:26.1.0'
    implementation 'com.android.support:support-v4:26.1.0'
    implementation 'com.android.support:design:26.1.0'
    implementation 'com.android.support:support-v13:26.1.0'
    implementation 'com.android.support:appcompat-v7:26.1.0'
    //testImplementation 'junit:junit:4.12'
    //androidTestImplementation 'com.android.support.test:runner:1.0.1'
    //androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
    implementation 'com.github.boxme:squarecamera:1.1.0'
    implementation 'com.google.code.gson:gson:2.8.2'
    implementation 'com.squareup.picasso:picasso:2.5.2'
    implementation 'com.google.android.gms:play-services-maps:11.8.0'
    implementation 'com.google.android.gms:play-services-places:11.8.0'
    implementation 'com.google.android.gms:play-services-location:11.8.0'
    implementation 'com.schibstedspain.android:leku:4.0.1'
}

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
Bakyt-Itigulovcommented, Apr 14, 2018

Adding following options to build.gradle file in app module helped me.

compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 }

0reactions
ferranponscommented, May 25, 2020

Solved

Read more comments on GitHub >

github_iconTop Results From Across the Web

Building library failed with dex errors · Issue #154 - GitHub
Building library failed with dex errors #154 ... Removing the leku library and instances, it builds just fine without errors or warnings.
Read more >
android - Dex Error while building the project - Stack Overflow
I am getting the following error when I try to build my project. This error occurs when I was trying to add JavaMail...
Read more >
Build failure -- Error while merging dex archives - Unity Forum
I've encounted a build error on Android. Unity 2021 LTS, MacOS. Since it involves Gradle, it provides a sludge of error reports but...
Read more >
Compile Errors from Referencing More Than 65000 Methods
Build Errors from Referencing More Than 65,000 Methods​​ This error is caused by Android's limit of 65,535 method references for Dalvik executable (dex)...
Read more >
Error when compiling. Compile stops at DEX Step - B4X
I got a lot of errors in the DEX step. Dexing stopped at some time. B4A Version: 8.80. Parsing code. (0.25s) Building folders...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found