Android 应用程序 Gradle 构建错误“找不到 com.github.championswimmer:SimpleFingerGestures_Android_Library:1.2”

shi*_*ivi 4 android build android-build build.gradle

我正在尝试构建一个 Android 应用程序,它依赖于SimpleFingerGestures_Android_Library。应用程序的构建失败并出现以下错误 -

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':app:compileReleaseJavaWithJavac'.
> Could not resolve all task dependencies for configuration ':app:releaseCompileClasspath'.
   > Could not find com.github.championswimmer:SimpleFingerGestures_Android_Library:1.2.
     Required by:
         project
Run Code Online (Sandbox Code Playgroud)

下面是我将其依赖项包含在 build.gradle(app) 中的代码 -

dependencies {
    implementation 'com.github.championswimmer:SimpleFingerGestures_Android_Library:1.2'
}
Run Code Online (Sandbox Code Playgroud)

我还添加了 Maven 存储库 -

    repositories {
        jcenter()
        maven {
            url "https://jitpack.io"
        }
    }
Run Code Online (Sandbox Code Playgroud)

我的试用: 经过这么多次尝试,我发现如果我使用以前版本的库的依赖项进行编译,那么就没有问题了。所以下面的代码对我有用 -

dependencies {
    implementation 'com.github.championswimmer:SimpleFingerGestures_Android_Library:1.1'
}
Run Code Online (Sandbox Code Playgroud)

问题摘要:我想包含最新版本的 SFG 1.2 ,但构建失败。然而,SFG Lib 的先前版本(1.1)的构建正在通过。

注意:我没有使用 AndroidStudio 进行构建,而是使用命令行 gradlew 实用程序(因为其他代码依赖项)。不过我尝试过 Android Studio 也有同样的问题。

小智 9

您应该maven { url "https://jitpack.io" }settings.gradle文件中添加。

dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
        maven { url "https://jitpack.io" }
    }
}
Run Code Online (Sandbox Code Playgroud)