0

I'm facing this problem when trying to run my app using the new Material Design library, please someone with a solution?

Log:

Executing tasks: [:app:assembleProdDebug]

:app:preBuild UP-TO-DATE :app:preProdDebugBuild UP-TO-DATE :app:compileProdDebugAidl UP-TO-DATE :app:compileProdDebugRenderscript UP-TO-DATE :app:checkProdDebugManifest UP-TO-DATE :app:generateProdDebugBuildConfig UP-TO-DATE :app:prepareLintJar UP-TO-DATE :app:mainApkListPersistenceProdDebug UP-TO-DATE :app:generateProdDebugResValues UP-TO-DATE :app:generateProdDebugResources UP-TO-DATE :app:mergeProdDebugResources UP-TO-DATE :app:createProdDebugCompatibleScreenManifests UP-TO-DATE :app:processProdDebugManifest UP-TO-DATE :app:splitsDiscoveryTaskProdDebug UP-TO-DATE :app:processProdDebugResources :app:generateProdDebugSources :app:javaPreCompileProdDebug Note: Some input files use unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. :app:compileProdDebugJavaWithJavac :app:compileProdDebugNdk NO-SOURCE :app:compileProdDebugSources :app:mergeProdDebugShaders UP-TO-DATE :app:compileProdDebugShaders UP-TO-DATE :app:generateProdDebugAssets UP-TO-DATE :app:mergeProdDebugAssets UP-TO-DATE :app:transformClassesWithDexBuilderForProdDebug AGPBI: {"kind":"error","text":"Program type already present: android.support.v4.app.INotificationSideChannel$Stub","sources":[{}],"tool":"D8"} :app:transformDexArchiveWithExternalLibsDexMergerForProdDebug FAILED

FAILURE: Build failed with an exception.

I'm using Android studio 3.1.3

Top gradle:

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

buildscript {

    repositories {
        google()
        jcenter()
        maven {
            url "https://maven.google.com"
        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.3'

        // 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
}

// Define versions in a single place
ext {
    // Sdk and tools
    minSdkVersion = 15
    targetSdkVersion = 27
    compileSdkVersion = 'android-P'
    buildToolsVersion = '28.0.0-rc2'

    // App dependencies
    supportLibraryVersion = '28.0.0-alpha1'
    constraintLayout = '1.1.0'
    volley = '1.0.0'
    gson = '2.7'
    butterKnife = '8.8.1'
    analytics = '16.0.0'
    guavaVersion = '18.0'
    picassoVersion = '2.5.2'
    junitVersion = '4.12'
    mockitoVersion = '1.10.19'
    powerMockito = '1.6.2'
    hamcrestVersion = '1.3'
    runnerVersion = '1.1.0-alpha1'
    rulesVersion = '1.1.0-alpha1'
    espressoVersion = '3.1.0-alpha3'
}

App Gradle file:

apply plugin: 'com.android.application'

android {
    compileSdkVersion rootProject.ext.compileSdkVersion
    buildToolsVersion rootProject.ext.buildToolsVersion

    defaultConfig {
        applicationId "com.test.bnl"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
    }

    buildTypes {
        debug {
            // Run code coverage reports by default on debug builds.
            // testCoverageEnabled = true
            applicationIdSuffix ".debug"
            debuggable true
        }

        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    // Specifies flavor dimensions.
    flavorDimensions "default"

    // If you need to add more flavors, consider using flavor dimensions.
    productFlavors {
        mock {
            applicationIdSuffix ".mock"
            versionNameSuffix "-mock"
        }

        prod {
            applicationIdSuffix ".prod"
            versionNameSuffix "-prod"
        }
    }

    // Remove mockRelease as it's not needed.
    android.variantFilter { variant ->
        if (variant.buildType.name == 'release' && variant.getFlavors().get(0).name == 'mock') {
            variant.setIgnore(true)
        }
    }

    // Always show the result of every unit test, even if it passes.
    testOptions.unitTests.all {
        testLogging {
            events 'passed', 'skipped', 'failed', 'standardOut', 'standardError'
        }
    }

}

/*
 Dependency versions are defined in the top level build.gradle file. This helps keeping track of
 all versions in a single place. This improves readability and helps managing project complexity.
 */
dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])

    // App's dependencies, including test
    implementation 'com.google.android.material:material:1.0.0-alpha3'

    implementation "com.google.guava:guava:$rootProject.guavaVersion"
    implementation "com.squareup.picasso:picasso:$rootProject.picassoVersion"
    implementation "androidx.test.espresso:espresso-idling-resource:$rootProject.ext.espressoVersion"

    implementation "com.android.volley:volley:$rootProject.ext.volley"
    implementation "com.google.code.gson:gson:$rootProject.ext.gson"
    implementation "com.google.android.gms:play-services-analytics:$rootProject.ext.analytics"

    // Dependencies for local unit tests
    testImplementation "junit:junit:$rootProject.ext.junitVersion"
    testImplementation "org.mockito:mockito-all:$rootProject.ext.mockitoVersion"
    testImplementation "org.hamcrest:hamcrest-all:$rootProject.ext.hamcrestVersion"
    testImplementation "org.powermock:powermock-module-junit4:$rootProject.ext.powerMockito"
    testImplementation "org.powermock:powermock-api-mockito:$rootProject.ext.powerMockito"

    // Android Testing Library's runner and rules
    androidTestImplementation "androidx.test:runner:$rootProject.ext.runnerVersion"
    androidTestImplementation "androidx.test:rules:$rootProject.ext.rulesVersion"

    // Espresso UI Testing dependencies.
    androidTestImplementation "androidx.test.espresso:espresso-core:$rootProject.ext.espressoVersion"
    androidTestImplementation "androidx.test.espresso:espresso-contrib:$rootProject.ext.espressoVersion"
    androidTestImplementation "androidx.test.espresso:espresso-intents:$rootProject.ext.espressoVersion"
    implementation 'junit:junit:4.12'
}

Gradle.properties:

# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx1536m
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true

android.useAndroidX=true
android.enableJetifier=false

If more information is needed, let me know!

GFPF
  • 959
  • 14
  • 19
  • Possible duplicate of [Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat](https://stackoverflow.com/questions/20989317/multiple-dex-files-define-landroid-support-v4-accessibilityservice-accessibility) – GFPF Jun 26 '18 at 19:23
  • I found a solution and posted here: http://stackoverflow.com/a/51049986/3033184 – GFPF Jun 26 '18 at 19:19
  • Check https://stackoverflow.com/questions/51918301/program-type-already-present-android-support-v4-app-inotificationsidechannelst/54178126#54178126 – Jose Jan 14 '19 at 08:50

2 Answers2

0

Android Studio 3.2+ resolves this issue. It also adds a "Migrate to AndroidX" item under the Refactor menu.

Always Lucky
  • 334
  • 3
  • 7
0

Migrate to androidx or upgrade your build.gradle version

Rahul Goswami
  • 762
  • 6
  • 18