SwipeDelMenuLayout失效:Could not find SwipeDelMenuLayout-V1.3.0.jar

一、问题描述

        最近在工作上的项目中接触到SwipeDelMenuLayout这个第三方Android开发库,然后我就根据网上的教程进行配置。这里先说一下我的开发环境:Android Studio版本是android-studio-2020.3.1.24-windows,gradle版本是7.0.2。

SwipeDelMenuLayout失效:Could not find SwipeDelMenuLayout-V1.3.0.jar_第1张图片

        首先是在settings.gradle文件中添加jitpack仓库,而不是build.gradle文件(这么做的原因是参考了别人的资料:https://www.jdk5.com/ask/34/build-was-configured-to-prefer-settings-repositories-over-project-repositories-b)。添加的这一行代码是

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

        然后整个settings.gradle文件变成

dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
        maven { url 'https://jitpack.io' }
    }
}
rootProject.name = "SwipeDelDemo"
include ':app'

        然后在build.gradle (Module)文件中添加依赖

implementation 'com.github.mcxtzhang:SwipeDelMenuLayout:V1.3.0'

        该文件的依赖就变成如下

dependencies {

    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'com.google.android.material:material:1.3.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
    testImplementation 'junit:junit:4.+'
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'


    implementation 'com.github.mcxtzhang:SwipeDelMenuLayout:V1.3.0'
}

        之后就可以编译使用SwipeDelMenuLayout这个库了。但是,编译的时候却遇到了来自Android Studio的编译报错,说

Could not find SwipeDelMenuLayout-V1.3.0.jar (com.github.mcxtzhang:SwipeDelMenuLayout:V1.3.0).

        然后我去访问地址:https://jitpack.io/com/github/mcxtzhang/SwipeDelMenuLayout/V1.3.0/SwipeDelMenuLayout-V1.3.0.jar,浏览器显示Build failed. See the log at jitpack.io。具体的报错信息如下:

SwipeDelMenuLayout失效:Could not find SwipeDelMenuLayout-V1.3.0.jar_第2张图片

        上面的报错表明这个库确实引用不了。我以为是我配置错了,但跟着别人的方式配置,Android Studio报的编译错误会更加多。

        如果我删掉

implementation 'com.github.mcxtzhang:SwipeDelMenuLayout:V1.3.0'

        这样项目瞬间没事,直接运行。当然这个不是解决方案,哈哈。

二、解决方案

        官方文档我来来回回又看了好几遍,然后有重大发现!!

        该三方库的开源作者在CSDN博客推荐使用的版本号是SwipeDelMenuLayout:V1.2.1,如图:

SwipeDelMenuLayout失效:Could not find SwipeDelMenuLayout-V1.3.0.jar_第3张图片

        但在GitHub上的readme.md文档中却写着SwipeDelMenuLayout:V1.3.0,如图:

SwipeDelMenuLayout失效:Could not find SwipeDelMenuLayout-V1.3.0.jar_第4张图片

        我相信作者应该是忘了及时更新文档,所以在调用方面所写的版本号存在着差异。最终,别人在引用该库的时候,有些用V1.2.1,而有些用V1.3.0。这两个版本号应该都是没有问题的,但是最近(2023年7月下旬),我猜测可能是V1.3.0这个版本的jitpack仓库出现了问题,所以导致了项目的编译报错问题。猜测的原因:作者主动撤销了,或者仓库被删除了。

        所以,最终的解决方案是:如果用SwipeDelMenuLayout:V1.3.0报错,就把它改成SwipeDelMenuLayout:V1.2.1。

三、参考资料

        1、【Android】史上最简单,一步集成侧滑(删除)菜单,高仿QQ、IOS

        2、GitHub - mcxtzhang/SwipeDelMenuLayout

你可能感兴趣的:(Android,第三方库)