【问题标题】:Can't use Jitpack dependencies无法使用 Jitpack 依赖项
【发布时间】:2021-11-14 23:18:16
【问题描述】:

尝试使用来自 Jitpack 的 ImagePicker,但是即使按照添加依赖项的步骤,它也不会导入到我的代码中。

settings.gradle

dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
    google()
    mavenCentral()
    jcenter() // Warning: this repository is going to shut down soon
    maven { url "https://jitpack.io" }
}
}
rootProject.name = "Flower Identifier v1"
include ':app'

build.gradle

dependencies {

implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.3.1'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1'
implementation 'androidx.navigation:navigation-fragment-ktx:2.3.5'
implementation 'androidx.navigation:navigation-ui-ktx:2.3.5'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
implementation 'com.github.jkwiecien:EasyImage:Tag'
implementation 'com.github.Dhaval2404:ImagePicker:Tag'
}

ImagePicker 未正确导入:

还尝试从 settings.gradle 中删除 repos 并将其添加到 build.gradle,如下所示:

allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}

但还是有同样的问题

【问题讨论】:

    标签: android-studio kotlin gradle jitpack


    【解决方案1】:

    首先你需要声明这个库的版本。改变

    implementation 'com.github.jkwiecien:EasyImage:Tag'
    implementation 'com.github.Dhaval2404:ImagePicker:Tag'
    

    到指定的版本标签,如implementation 'com.github.dhaval2404:imagepicker:2.1'

    然后你可以删除

    allprojects {
        repositories {
            ...
            maven { url 'https://jitpack.io' }
        }
    }
    

    形成build.gradle

    【讨论】:

    • 感谢整理
    猜你喜欢
    • 1970-01-01
    • 2019-02-23
    • 2021-10-20
    • 2021-12-09
    • 1970-01-01
    • 2017-05-06
    • 2021-08-28
    • 2021-11-18
    • 1970-01-01
    相关资源
    最近更新 更多