Google material design library error Program type already present: android.support.v4.app.INotificationSideChannel$Stub$Proxy
Whenever i add implemntation 'com.google.android.material:material:1.0.0-alpha1'
when i try to build my project Android Studio says:
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)}
This is my gradle script:
apply plugin: 'com.android.application'
android {
compileSdkVersion 'android-P'
defaultConfig {
applicationId "it.smart.bab3"
minSdkVersion 21
targetSdkVersion 'p'
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0-alpha1'
implementation 'com.google.android.material:material:1.0.0-alpha1'
implementation 'com.android.support.constraint:constraint-layout:1.1.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'
implementation 'com.android.support:design:28.0.0-alpha1'
implementation 'com.android.support:support-v4:28.0.0-alpha1'
}
I'm new ith this type of errors, and i didn't find anithing with this error. Thanks
Solution 1:
I've been struggling all day with this issue too. Finally I managed to compile and run the project successfully.
First of all, get rid of this:
implementation 'com.android.support:appcompat-v7:28.0.0-alpha1'
implementation 'com.android.support:design:28.0.0-alpha1'
implementation 'com.android.support:support-v4:28.0.0-alpha1'
Add the following in your gradle.properties file:
android.useAndroidX = true
android.enableJetifier = false
And finally, sync the project and then compile.
If it doesn't work, clean the project and then rebuild.
PS: I can't get targetSdkVersion 'p' to work. My build.gradle file end up as follows:
apply plugin: 'com.android.application'
android {
compileSdkVersion 'android-P'
defaultConfig {
applicationId "com.github.alvarosct02.demo"
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'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.google.android.material:material:1.0.0-alpha1'
implementation 'com.android.support.constraint:constraint-layout:1.1.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'
}
Hope it works for you too.
Solution 2:
I wasted 2 days looking for a solution. Anyone who's still looking for a solution can follow the steps below:
Update your Android Studio to the latest version.
-
Update your compileSdkVersion and targetSdkVersion to 28.
android { compileSdkVersion 28 defaultConfig { applicationId "com.your.appid" minSdkVersion 19 targetSdkVersion 28 versionCode 50 versionName "1.50" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" multiDexEnabled true setProperty("archivesBaseName", "your-app-$versionName") resConfigs "en" } }
Go to your project structure and change your gradle version to 4.10.
-
Add this dependency first:
implementation 'com.google.android.material:material:1.0.0'
-
Now remove all the support library dependencies:
implementation "com.android.support:design:$SUPPORT_LIBRARY_VERSION" implementation "com.android.support:support-v4:$SUPPORT_LIBRARY_VERSION" implementation "com.android.support:appcompat-v7:$SUPPORT_LIBRARY_VERSION" implementation "com.android.support:recyclerview-v7:$SUPPORT_LIBRARY_VERSION" implementation "com.android.support:cardview-v7:$SUPPORT_LIBRARY_VERSION" implementation 'com.android.support.constraint:constraint-layout:1.1.3' implementation 'com.android.support:multidex:1.0.3' testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" androidTestImplementation('com.android.support.test.espresso:espresso- core:2.2.2', { exclude group: 'com.android.support', module: 'support-annotations' exclude group: 'com.google.code.findbugs', module: 'jsr305' })
-
Now paste the following into your gradle.properties file:
android.useAndroidX = true android.enableJetifier = true
-
In your project level build.gradle file:
dependencies { classpath 'com.android.tools.build:gradle:3.2.0' classpath 'com.google.gms:google-services:4.1.0' };
For those who are using Butterknife add below lines in your project level build.gradle file:
allprojects {
repositories {
google()
jcenter()
maven { url "https://jitpack.io" }
maven { url "https://dl.bintray.com/drummer-aidan/maven/" }
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
}
}
And in your module build.gradle file add below dependencies:
implementation "com.jakewharton:butterknife:9.0.0-SNAPSHOT"
annotationProcessor "com.jakewharton:butterknife-compiler:9.0.0-SNAPSHOT"
- Now Goto Build > Rebuild Project then you might be getting a lot of errors.
- Now refer this link.
It has the list of all the old (android.support) vs new (androidx.*) dependencies.
Replace all your old imports with the new ones
(Use replaceAll feature of android studio [ctrl + shift + R] which will save you some time).
- Finally After refactoring all the old libraries with the new ones:
Rebuild the project again and hopefully it should work.
Note: You can also use Refactor > Migrate to androidx in android studio but it didn't work for me.
Solution 3:
I started getting this error after upgrading the ButterKnife to the version 8.8.1.
So, I run the command gradle -q dependencies
to generate a dependency report, after that you should see where D8 is coming from. In my case from the "ButterKnife" library:
+--- com.jakewharton:butterknife:8.8.1
| | \--- com.android.support:support-compat:d8
Also you can see your android dependencies by going to your Android Studio Gradle view (In Android Studio tool bar navigate to "View/Tool Windows/Gradle"), and selecting the target "androidDependencies" under "My-Project-Name/Tasks/android" (Double click to run or Right click and run).
To solve this problem I added this piece of code exclude module: 'support-compat'
to my "app/build.gradle" as below:
implementation ('com.jakewharton:butterknife:8.8.1') {
exclude module: 'support-compat'
}
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
Hope it works for someone else :] Cheers!
Solution 4:
Android Studio v3.2+ resolves this issue. It also adds a "Migrate to AndroidX" item under the Refactor menu. No work-around or rollback required.
Update Android Studio from the beta channel to use 3.2+ or wait until a stable version is released.
EDIT: Android Studio v3.2 is now in the stable channel. It is important you no longer use the support libraries and migrate to AndroidX libraries because support for the old support libraries has ended.