React Native install react-native-google-cast错误Android依赖项'com.android.support:support-v4'具有不同的编译版本

时间:2019-01-08 08:54:14

标签: java android react-native android-gradle build.gradle

我安装了模块react-native-google-cast,并按照说明添加了以下几行:

implementation "com.google.android.gms:play-services-cast:9.8.0"
implementation "com.android.support:mediarouter-v7:28.0.0"

我的项目的配置如下:

ext {
         buildToolsVersion = "28.0.0"
         minSdkVersion = 16
         compileSdkVersion = 28
         targetSdkVersion = 28
         supportLibVersion = "28.0.0"
     }

出现以下错误:

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

我也尝试过这一点,正如在stackoverflow上许多线程中所建议的那样,但是我无法解决问题。 请参见下面的代码,添加到根版本中。

subprojects {
    project.configurations.all {
        resolutionStrategy.eachDependency { details ->
            if (details.requested.group == 'com.android.support'
                && !details.requested.name.contains('multidex') ) {
                details.useVersion "28.0.0"
            }
        }
    }
}

或者:

configurations.all {
  resolutionStrategy.eachDependency { details ->
      if (details.requested.group == 'com.android.support'
              && !details.requested.name.contains('multidex') ) {
          details.useVersion "28.0.0"
      }
  }
}

有人可以帮我吗?

0 个答案:

没有答案