影子罐,以避免在Android Studio中重复依赖项

问题描述

我正在android studio中构建一个android应用程序,但是在重复依赖项方面遇到了麻烦。

Duplicate class javax.inject.Inject found in modules jetified-javax.inject-1.jar (javax.inject:javax.inject:1) and jetified-javax.inject-2.5.0-b42.jar (org.glassfish.hk2.external:javax.inject:2.5.0-b42)

这两个依赖关系对我来说都是非常有用的,我尝试从这两个依赖关系中排除有问题的部分,而这最终破坏了另一个依赖关系。

我一直在阅读有关影子罐子的信息,据我所知听起来像是魔术子弹,所以我尝试了一下。从我阅读和听到的内容中,您只是将其添加为依赖项,并且它神奇地修复了所有问题。我尝试添加它,但是仍然出现错误,但是我在线阅读了一下,如果您希望它能完成很多工作,则必须安装java或groovy插件。这些都使android studio非常不高兴,因为android自己修改了Java或其他内容

关于如何使影子罐工作的建议将不胜感激,但是如果有人有其他解决方法,也可以让我继续使用我喜欢听到的两个相互冲突的依赖项。对不起,如果我犯了一些新手错误

我的gradle文件

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
    compileSdkVersion 29
    buildToolsversion "29.0.3"

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    defaultConfig {
        applicationId "com.example.scrood"
        minSdkVersion 16
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"
        multiDexEnabled true

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'),'proguard-rules.pro'
        }
    }

}

dependencies {
    implementation filetree(dir: 'libs',include: ['*.jar'])
    implementation 'com.github.jengelman.gradle.plugins:shadow:6.0.0'
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.core:core-ktx:1.3.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'com.android.support:multidex:1.0.3'
    implementation 'com.squareup.picasso:picasso:2.5.1'
    implementation 'org.glassfish.jersey.core:jersey-client:2.27'
    implementation 'org.glassfish.jersey.media:jersey-media-json-jackson:2.27'
    implementation 'com.fasterxml.jackson.module:jackson-module-kotlin:2.10.4'
    implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.10.4'
    implementation 'com.google.android.gms:play-services-maps:17.0.0'
    implementation ('com.google.android.libraries.places:places:2.3.0')
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)