错误:程序类型已存在:android.support.v4.app.INotificationSideChannel$Stub
我已将Firebase数据库集成到我的Android应用程序中,并得到如下错误:错误:程序类型已存在:android.support.v4.app.INotificationSideChannel$Stub,android,android-studio,android-gradle-plugin,build.gradle,androidx,Android,Android Studio,Android Gradle Plugin,Build.gradle,Androidx,我已将Firebase数据库集成到我的Android应用程序中,并得到如下错误: Error:Program type already present: android.support.v4.app.INotificationSideChannel$Stub apply plugin: 'com.android.application' android { compileSdkVersion 28 defaultConfig {
Error:Program type already present: android.support.v4.app.INotificationSideChannel$Stub
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.bestofapps.task.mycuteapp"
minSdkVersion 16
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
dataBinding {
enabled = true
}
compileOptions {
targetCompatibility 1.8
sourceCompatibility 1.8
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation pri.support.appcompat
implementation pri.support.design
implementation pri.support.cardview
implementation pri.support.recyclerview
implementation pri.support.constraint
//Lifecycle
implementation "android.arch.lifecycle:extensions:1.1.1"
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
annotationProcessor "android.arch.lifecycle:compiler:1.1.1"
//Firebase
//noinspection GradleCompatible
implementation 'com.google.firebase:firebase-database:19.1.0'
implementation 'com.google.firebase:firebase-config:19.0.1'
implementation 'com.google.firebase:firebase-core:17.2.0'
implementation 'com.google.firebase:firebase-messaging:20.0.0'
implementation 'com.google.firebase:firebase-analytics:17.2.0'
implementation 'com.android.support:multidex:1.0.3'
implementation("com.github.bumptech.glide:glide:4.8.0@aar") {
transitive = true
}
// Glide v4
annotationProcessor 'com.github.bumptech.glide:compiler:4.8.0'
//Google Map
implementation 'com.google.android.gms:play-services-maps:15.0.1'
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'
}
apply plugin: 'com.google.gms.google-services'
You can also check my build.gradle file as below : (Project Level)
// 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.3'
classpath 'com.google.gms:google-services:4.0.1'
// 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
}
apply from: './build_version.gradle'
您可以按如下方式检查我的gradle文件:
Error:Program type already present: android.support.v4.app.INotificationSideChannel$Stub
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.bestofapps.task.mycuteapp"
minSdkVersion 16
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
dataBinding {
enabled = true
}
compileOptions {
targetCompatibility 1.8
sourceCompatibility 1.8
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation pri.support.appcompat
implementation pri.support.design
implementation pri.support.cardview
implementation pri.support.recyclerview
implementation pri.support.constraint
//Lifecycle
implementation "android.arch.lifecycle:extensions:1.1.1"
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
annotationProcessor "android.arch.lifecycle:compiler:1.1.1"
//Firebase
//noinspection GradleCompatible
implementation 'com.google.firebase:firebase-database:19.1.0'
implementation 'com.google.firebase:firebase-config:19.0.1'
implementation 'com.google.firebase:firebase-core:17.2.0'
implementation 'com.google.firebase:firebase-messaging:20.0.0'
implementation 'com.google.firebase:firebase-analytics:17.2.0'
implementation 'com.android.support:multidex:1.0.3'
implementation("com.github.bumptech.glide:glide:4.8.0@aar") {
transitive = true
}
// Glide v4
annotationProcessor 'com.github.bumptech.glide:compiler:4.8.0'
//Google Map
implementation 'com.google.android.gms:play-services-maps:15.0.1'
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'
}
apply plugin: 'com.google.gms.google-services'
You can also check my build.gradle file as below : (Project Level)
// 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.3'
classpath 'com.google.gms:google-services:4.0.1'
// 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
}
apply from: './build_version.gradle'
我还在AndroidManifest.xml文件中指定了所需的Internet权限:
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission. ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
请导游
可能有什么问题?您正在使用需要androidx迁移的firebase库。你不能使用android支持库。这就是为什么像上面那样做:android.useAndroidX=true可能是不够的。在build.gradle中更改依赖项