首页 > 解决方案 > 依赖解析错误?科特林

问题描述

我得到了这个错误,我不知道如何解决它。

错误

这些是我在应用程序中的依赖项


dependencies {
    implementation 'androidx.core:core-ktx:1.6.0'
    implementation 'androidx.appcompat:appcompat:1.3.1'
    implementation 'com.google.android.material:material:1.4.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.1'
    implementation 'com.google.firebase:firebase-database-ktx'
    implementation 'com.google.firebase:firebase-analytics-ktx'
    implementation platform('com.google.firebase:firebase-bom:28.4.1')
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'com.android.support:support-annotations:28.0.0'
    implementation 'androidx.annotation:annotation:1.2.0'
    implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.3.1'
    implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
    implementation 'com.jakewharton.timber:timber:4.7.1'
    implementation 'com.google.android.gms:play-services-maps:17.0.1'
    implementation ('com.google.zxing:core:3.3.3')
    implementation 'com.braintreepayments.api:drop-in:3.3.0'
    implementation 'com.android.volley:volley:1.2.1'
    implementation 'com.loopj.android:android-async-http:1.4.9'
}

请帮我解决这个错误?

已编辑

我更改了 minsdk 版本,但它显示了另一个错误,还添加了类似此错误的 uses-sdk 工具,但得到了同样的错误。

新错误

标签: androidkotlin

解决方案


当您添加两个包含相同类的依赖项时,会出现此问题。而且我认为被告应该是这种braintreepayments依赖,所以我建议更新

  implementation 'com.braintreepayments.api:drop-in:3.3.0'

更新版本

  implementation 'com.braintreepayments.api:drop-in:5.2.2'

当然,您已经将 mven repo 添加到您的项目 gradle 文件中。

repositories {
    maven {
        url "https://cardinalcommerceprod.jfrog.io/artifactory/android"
        credentials {
            username 'braintree_team_sdk'
            password 'AKCp8jQcoDy2hxSWhDAUQKXLDPDx6NYRkqrgFLRc3qDrayg6rrCbJpsKKyMwaykVL8FWusJpp'
        }
    }
}

更多信息,请查看: https ://github.com/braintree/braintree-android-drop-in

已编辑

不要忘记设置 min sdk 版本 21 或以上

defaultConfig {
        ...
        minSdkVersion 21
        ...   
    }

如果清单中存在,则删除此行

<uses-sdk android:minSdkVersion="16"/>

推荐阅读