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.

Build Error Android Program type already present: android.support.v4.app.BackStackState$1

See original GitHub issue

Hello i try to integrate Sonar to my android project, but i got error build

> Task :app:transformDexArchiveWithExternalLibsDexMergerForDebug FAILED
D8: Program type already present: android.support.v4.app.BackStackState$1


FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.

my build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext.kotlin_version = '1.2.41'
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.0-alpha18'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

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

and my app/build.gradle

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-android-extensions'

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "com.pratamawijaya.newsapimvvm"
        minSdkVersion 19
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

configurations.all {
    resolutionStrategy.eachDependency { DependencyResolveDetails details ->
        def requested = details.requested
        if (requested.group == 'com.android.support') {
            if (!requested.name.startsWith("multidex")) {
                details.useVersion '27.1.1'
            }
        } else if (requested.group == "com.google.android.gms") {
            details.useVersion '11.8.0'
        } else if (requested.group == "com.google.firebase") {
            details.useVersion '11.8.0'
        }

    }
}

dependencies {

    def room_version = "1.1.0"
    def support_version = "27.1.1"
    def dagger_version = "2.15"

    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation "com.android.support:appcompat-v7:$support_version"
    implementation "com.android.support:design:$support_version"
    implementation "com.android.support:support-v4:$support_version"
    implementation "com.android.support:cardview-v7:$support_version"

    implementation 'com.android.support.constraint:constraint-layout:1.1.0'
    implementation 'android.arch.lifecycle:extensions:1.1.1'

    implementation "android.arch.persistence.room:runtime:$room_version"
    kapt "android.arch.persistence.room:compiler:$room_version"
    // optional - RxJava support for Room
    implementation "android.arch.persistence.room:rxjava2:$room_version"

//    implementation 'com.nytimes.android:store3:3.0.1'

    implementation 'com.squareup.retrofit2:retrofit:2.4.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
    implementation 'com.squareup.retrofit2:adapter-rxjava2:2.4.0'
    implementation 'io.reactivex.rxjava2:rxandroid:2.0.2'
    implementation 'io.reactivex.rxjava2:rxjava:2.1.3'
    implementation 'com.squareup.okhttp3:logging-interceptor:3.8.0'

    implementation 'com.xwray:groupie:2.0.3'
    implementation 'com.xwray:groupie-kotlin-android-extensions:2.0.3'

    implementation 'com.github.bumptech.glide:glide:4.7.1'
    kapt 'com.github.bumptech.glide:compiler:4.7.1'

    // logger
    implementation 'com.github.ajalt:timberkt:1.5.0'

    // dagger
    implementation "com.google.dagger:dagger:$dagger_version"
    kapt "com.google.dagger:dagger-compiler:$dagger_version"
    implementation "com.google.dagger:dagger-android:$dagger_version"
    implementation "com.google.dagger:dagger-android-support:$dagger_version"
    kapt "com.google.dagger:dagger-android-processor:$dagger_version"

    debugImplementation 'com.facebook.sonar:sonar:0.+'

    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
larslibakcommented, Jun 20, 2018

I have the same error where Sonar is conflicting with my other dependencies.

0reactions
ManishSharmaApporiocommented, Oct 9, 2018

Program type already present: android.support.v4.app.FragmentTransitionCompat21$4 Message{kind=ERROR, text=Program type already present: android.support.v4.app.FragmentTransitionCompat21$4, sources=[Unknown source file], tool name=Optional.of(D8)}

Read more comments on GitHub >

github_iconTop Results From Across the Web

android.support.v4.app.BackStackState$1 - Stack Overflow
Program type already present : android.support.v4.app.BackStackState$1 · 'proguard-android.txt' · 'libs/dagger-1.2.2.jar' · 'libs/javax.inject-1.jar ...
Read more >
Program type already present: android.support.v4.app ...
I have made some changes recently (upgraded a facebook login component) and it started failing with this error… *** Wha…
Read more >
android.support.v4.app.BackStackState$1 – iTecNote
Here is the error I'm facing while compiling the code: Program type already present: android.support.v4.app.BackStackState$1 Message{kind=ERROR, ...
Read more >
Error while merging dex Program type already present
D8: Program type already present : android. support. v4. app.INotificationSideChannelFAILURE: Build failed with an exception.
Read more >
Error: Program type already present: android.support.v4.os ...
I have a build an Android app. to control a robot using ROSJava. I can successfully connect to the robot ROS Master and...
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