Android Studio中的jar问题

今天在项目中遇到了一个很奇葩的问题,

Android dependency 'com.android.support:support-support-v4' has different version for the compile (23.2.0) and runtime (27.0.2) classpath. You should manually set the same version via DependencyResolution.

很明显这是我们导入了两个不同版本的jar导致的,因此我们要想办法解决,找了一下,经过自己的理解,只需要在根项目的build.gradle中配置如下配置:

impletation("com.android.support:27.0.2") {
        exclude group: 'com.android.support', module: 'support-compat'
    }
    subprojects {
        project.configurations.all {
            resolutionStrategy.eachDependency { details ->
                if (details.requested.group == 'com.android.support:appcompat-v7'
                        && !details.requested.name.contains('multidex') ) {
                    details.useVersion "27.0.2"
                }
            }
        }

    }

然后重新build一下即可,

发布了8 篇原创文章 · 获赞 4 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/honey_angle_first/article/details/79986998