美文网首页
配置第三方库版本号

配置第三方库版本号

作者: 緦菍亭芷 | 来源:发表于2022-11-05 12:09 被阅读0次

    ./gradlew -q dependencies xrz_android:dependencies --configuration implementation

    ./gradlew -q dependencies base:dependencies --configuration implementation

    app目录 build.gradle

        configurations.all {
            //循环一个个的依赖库
            resolutionStrategy.eachDependency { DependencyResolveDetails details ->
                //获取当前循环到的依赖库
                def requested = details.requested
                //如果这个依赖库群组的名字是com.android.support
                if (requested.group == 'com.android.support') {
                    //且其名字不是以multidex开头的
                    if (!requested.name.startsWith("multidex")) {
                        //这里指定需要统一的依赖版本
                        details.useVersion '28.0.0'
                    }
                }
            }
        }
    

    根目录 build.gradle

    subprojects {
        project.evaluationDependsOn(':app')
        project.configurations.all {
            resolutionStrategy.eachDependency { details ->
    //            if (details.requested.group == 'androidx.core' &&
    //                    !details.requested.name.contains('androidx')) {
    //                details.useVersion "1.0.1"
    //            }
    //            def requested = details.requested
    //            if(requested.group == 'androidx.core'){
    //                details.useVersion "1.1.0"
    //            }
    //            if (requested.group == 'androidx.appcompat') {
    //                details.useVersion "1.1.0"
    //            }
    //            if (requested.group == 'androidx.fragment') {
    //                details.useVersion "1.0.0"
    //            }
    //            if (requested.group == 'androidx.recyclerview') {
    //                details.useVersion "1.1.0"
    //            }
                def requested = details.requested
                if (requested.group == 'androidx.activity') {
                    details.useVersion "1.2.4"
                }
            }
        }
    }
    

    相关文章

      网友评论

          本文标题:配置第三方库版本号

          本文链接:https://www.haomeiwen.com/subject/lexleltx.html