14

I know it could look like This Question but I could not fix it with the solution proposed and I could not comment on it too. The Error is :

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

I'm trying to create an app using firebase there's is my gradle file

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
    minSdkVersion 27
    targetSdkVersion 28
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
aaptOptions {
    noCompress "tflite"
}
}

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'androidx.appcompat:appcompat:1.0.0-rc01'
implementation 'androidx.constraintlayout:constraintlayout:1.1.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.0-alpha4'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha4'
implementation 'com.google.android.material:material:1.0.0-rc01'
implementation 'androidx.cardview:cardview:1.0.0-rc01'

// ML Kit dependencies
implementation 'com.google.firebase:firebase-core:16.0.1'
implementation 'com.google.firebase:firebase-ml-vision:17.0.0'
}
apply plugin: 'com.google.gms.google-services'

I pass over every file to be sure the import was good, I Also add

android.useAndroidX = true
android.enableJetifier = false

There's my Project Gradle file :

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

buildscript {

repositories {
    google()
    jcenter()
}
dependencies {
    classpath 'com.android.tools.build:gradle:3.1.4'
    classpath 'com.google.gms:google-services:4.1.0'


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

I use Android Studio 3.1.4

KerberosMorphy
  • 330
  • 1
  • 4
  • 14
  • 1
    For now, I just stop using androidx and it's working as fine as possible, I still hope being able to find the problem and merging to androidx – KerberosMorphy Sep 04 '18 at 14:13
  • 1
    I answered it [here](https://stackoverflow.com/a/52560036/6570945). Hope it works for you. – Ashu Tyagi Sep 28 '18 at 17:31
  • Thanks @AshuTyagi, I was able to migrate. I use your [solution](https://stackoverflow.com/a/52560036/6570945) + the **Refractor > Migrate to AndroidX**. After that, I review my import to migrate them manually to androidx (the Nullable for example). It compiles and run but my apps can’t start on my device anymore, I’ll have to find out why but still closer to the solution than before. – KerberosMorphy Sep 29 '18 at 03:45
  • libGDX project check this : https://stackoverflow.com/a/61377080/5733853 – VahidHoseini Apr 22 '20 at 23:59

5 Answers5

26

This happened to me when I tried to migrate to Android X.The reason behind is that not all libraries have been migrated to Android X.

  • You may manually remove dependencies. : Try to see all dependencies and find out the conflicting one. You may use Gradle View plugin for Android Studio or use class navigation from menu. (In android Studio: Navigation -> class; Now a search box appears and tick 'include non project items'; paste the whole class name creating error and search now; Find out the class having this dependency and remove manually!). Please check if you have any import statements left in files which uses the non AndoirdX dependencies still. If yes, please remove them too.

or

  • In Android studio, Refractor -> Migrate to AndroidX.

or alternatively(manual way)

  • add following to gradle.properties .
   android.useAndroidX=true
   android.enableJetifier=true

This makes Android Studio to migrate all dependencies. For more info please check here

Jose
  • 2,479
  • 1
  • 20
  • 17
7

I have a similar problem. In my case, it was because I am using Glide library and androidx. This solution works for me:

  1. Set enableJetifier value to true
  2. Update Gradle build tool to 3.3.0-alpha08 with Gradle version 4.9

source

sigitbn
  • 106
  • 3
2

in my case just change your firebase version from

implementation 'com.google.firebase:firebase-auth:19.1.0'

to implementation 'com.google.firebase:firebase-auth:16.1.0'

Ravi.Sh
  • 187
  • 2
  • 6
0

you can correct it by adding these to your gradle.properties

   android.useAndroidX=true
   android.enableJetifier=true

but in some cases it wont be correct like libGDX games to work correctly in libGDX games you should change these codes in build.gradle:

configurations.natives.files.each { jar ->
        def outputDir = null
        if(jar.name.endsWith("natives-arm64-v8a.jar")) outputDir = file("libs/arm64-v8a")
        if(jar.name.endsWith("natives-armeabi-v7a.jar")) outputDir = file("libs/armeabi-v7a")
        if(jar.name.endsWith("natives-armeabi.jar")) outputDir = file("libs/armeabi")
        if(jar.name.endsWith("natives-x86_64.jar")) outputDir = file("libs/x86_64")
        if(jar.name.endsWith("natives-x86.jar")) outputDir = file("libs/x86")
        if(outputDir != null) {
            copy {
                from zipTree(jar)
                into outputDir
                include "*.so"
            }
        }
    }

to this:

configurations.getByName("natives").copy().files.each { jar ->
    def outputDir = null
    if (jar.name.endsWith("natives-armeabi-v7a.jar")) outputDir = file("libs/armeabi-v7a")
    if (jar.name.endsWith("natives-armeabi.jar")) outputDir = file("libs/armeabi")
    if (jar.name.endsWith("natives-arm64-v8a.jar")) outputDir = file("libs/arm64-v8a")
    if (jar.name.endsWith("natives-x86.jar")) outputDir = file("libs/x86")
    if (jar.name.endsWith("natives-x86_64.jar")) outputDir = file("libs/x86_64")
    if (outputDir != null) {
        copy {
            from zipTree(jar)
            into outputDir
            include "*.so"
        }
    }
}

it will work correctly.

VahidHoseini
  • 495
  • 2
  • 10
  • 28
0

In Android Studio menu Navigate --> Class --> All (check that "Include in all places" checkbox is on) type your Class (INotificationSideChannel) and you will see more than one package of dependencies - just remove one of it from your gradle.build! It often problem when you use both android and androidx dependencies in one project.

Konstantin
  • 159
  • 7