Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Program type already present: android.support.v4.media.MediaBrowserCompat$ConnectionCallback$StubApi21

Received this error after updating android to preview p and adding material design library. refactored to suggested androidx namespaces.

here is my app.gradle file

apply plugin: 'kotlin-android' apply plugin: 'io.fabric' apply plugin: 'com.android.application'

buildscript {
repositories {
    maven { url 'https://maven.fabric.io/public' }
}

dependencies {
    classpath 'io.fabric.tools:gradle:1.25.4'
}

}

android {
lintOptions {
    checkReleaseBuilds false;
    abortOnError false
}

compileSdkVersion 'android-P'
useLibrary 'org.apache.http.legacy'

defaultConfig {
    applicationId "datazeo.android.dzreader"
    minSdkVersion 21

    targetSdkVersion 27

}

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

}

repositories {
mavenCentral()

maven {
    url 'https://maven.fabric.io/public'
}

}

dependencies {
implementation 'com.google.firebase:firebase-crash:15.0.2'
implementation 'com.google.firebase:firebase-core:15.0.2'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'org.jetbrains.anko:anko-common:0.9'
implementation 'com.commit451:PhotoView:1.2.4'
implementation('com.crashlytics.sdk.android:crashlytics:2.9.1') {
    transitive = true;

}
implementation 'com.google.android.material:material:1.0.0-alpha1'
implementation 'androidx.appcompat:appcompat:1.0.0-alpha1'
implementation 'androidx.legacy:legacy-support-v4:1.0.0-alpha1'
implementation 'androidx.legacy:legacy-support-core-utils:1.0.0-alpha1'

}

apply plugin: 'com.google.gms.google-services'
like image 670
mDiaz93 Avatar asked May 11 '18 23:05

mDiaz93


2 Answers

Specifically, I solved the problem by following on what's been described in this post. Although the post didn't tell us how to solve that problem, it actually is necessary for everything to work fine when using the new AndroidX library.

Just add the two lines below to gradle.properties file.

android.useAndroidX=true
android.enableJetifier=true

As for my case, simply updating the IDE to Android Studio Canary or even Android Studio Beta 1 doesn't solve the problem.

like image 120
Wei Avatar answered Nov 08 '22 04:11

Wei


Updating to android canary preview solved this issue for me.

like image 38
mDiaz93 Avatar answered Nov 08 '22 04:11

mDiaz93