我知道它可能看起来像This Question但我无法解决它提出的解决方案,我也无法评论它.
错误是:
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)}
我正在尝试使用firebase创建一个应用程序,这是我的gradle文件
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'
我传递每个文件,以确保导入是好的,我也添加
android.useAndroidX = true
android.enableJetifier = false
有我的Project Gradle文件:
// 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
}
我使用的是Android Studio 3.1.4
解决方法:
当我尝试迁移到Android X时发生了这种情况.背后的原因是并非所有库都已迁移到Android X.
>您可以手动删除依赖项. :尝试查看所有依赖项并找出冲突的依赖项.您可以使用Android Studio的Gradle View插件或使用菜单中的类导航. (在android Studio中:导航 – >类;现在出现一个搜索框并勾选’包含非项目项’;粘贴整个类名创建错误并立即搜索;找出具有此依赖关系的类并手动删除!).请检查在使用非AndoirdX依赖项的文件中是否还有任何import语句.如果是,请删除它们.
要么
>在Android studio中,Refractor – >迁移到AndroidX.
或者(手动方式)
>将以下内容添加到gradle.properties.
android.useAndroidX=true
android.enableJetifier=true
这使得Android Studio可以迁移所有依赖项.欲了解更多信息,请查看here