在build.gradle中实现MaterialProgressBar时,Appcompat依赖项出现错误

时间:2019-06-23 15:31:02

标签: android-studio kotlin build.gradle appcompat-v7

实施implementation 'com.android.support:appcompat-v7:28.0.0'后,在build.gradle文件中的implementation 'me.zhanghai.android.materialprogressbar:library:1.6.1'中出现错误

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.android.support:design:28.0.0'
    implementation 'me.zhanghai.android.materialprogressbar:library:1.6.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'
}

我已经尝试使用

android.useAndroidX=true and
android.enableJetifier=true

gradle.properties文件内部,但是我的MainActivity.kt文件又出现另一个错误

这是错误消息:

Dependencies using groupId com.android.support and androidx.* can not be combined but found IdeMavenCoordinates{myGroupId='com.android.support', myArtifactId='cardview-v7', myVersion='28.0.0', myPacking='aar', myClassifier='null'} and IdeMavenCoordinates{myGroupId='androidx.lifecycle', myArtifactId='lifecycle-viewmodel', myVersion='2.0.0', myPacking='aar', myClassifier='null'} incompatible dependencies less... (Ctrl+F1) 
Inspection info:There are some combinations of libraries, or tools and libraries, that are incompatible, or can lead to bugs. One such incompatibility is compiling with a version of the Android support libraries that is not the latest version (or in particular, a version lower than your targetSdkVersion).  Issue id: GradleCompatible

是否可以解决此错误?谢谢!

1 个答案:

答案 0 :(得分:0)

AndroidX和Compat不能一起使用,引入了AndroidX库来删除Compat库。 关掉     android.useAndroidX = false和     android.enableJetifier = true 发布您完整的应用gradle文件。您的依赖项中有一个库使用的版本比targetSdkVersion的版本低。