MapBox React Native:'无法解析com.squareup.okio:okio:1.13.0'

时间:2019-05-03 12:40:12

标签: react-native mapbox-gl

我尝试安装:MapBox,但是我有那些错误:

Could not resolve all files for configuration ':mapbox-react-native-mapbox- gl:debugCompileClasspath'.
> Could not resolve com.squareup.okio:okio:1.13.0.
Required by:
  project :mapbox-react-native-mapbox-gl
> Cannot find a version of 'com.squareup.okio:okio' that satisfies the version constraints:
    Dependency path 'projekt:mapbox-react-native-mapbox-gl:unspecified' --> 'com.facebook.react:react-native:0.59.6' --> 'com.squareup.okio:okio:1.15.0'
    Dependency path 'projekt:mapbox-react-native-mapbox-gl:unspecified' --> 'com.squareup.okhttp3:okhttp:3.9.1' --> 'com.squareup.okio:okio:1.13.0'
    Dependency path 'projekt:mapbox-react-native-mapbox-gl:unspecified' --> 'com.facebook.react:react-native:0.59.6' --> 'com.squareup.okhttp3:okhttp:3.9.1' --> 'com.squareup.okio:okio:1.13.0'
    Constraint path 'projekt:mapbox-react-native-mapbox-gl:unspecified' --> 'com.squareup.okio:okio' strictly '1.13.0' because of the following reason: debugRuntimeClasspath uses version 1.13.0
    Constraint path 'projekt:mapbox-react-native-mapbox-gl:unspecified' --> 'com.squareup.okio:okio' strictly '1.13.0' because of the following reason: debugRuntimeClasspath uses version 1.13.0
    Constraint path 'projekt:mapbox-react-native-mapbox-gl:unspecified' --> 'com.squareup.okio:okio' strictly '1.13.0' because of the following reason: debugRuntimeClasspath uses version 1.13.0
    Constraint path 'projekt:mapbox-react-native-mapbox-gl:unspecified' --> 'com.squareup.okio:okio' strictly '1.13.0' because of the following reason: debugRuntimeClasspath uses version 1.13.0

> Could not resolve com.squareup.okio:okio:1.15.0.
Required by:
  project :mapbox-react-native-mapbox-gl > com.facebook.react:react-native:0.59.6
> Cannot find a version of 'com.squareup.okio:okio' that satisfies the version constraints:
    Dependency path 'projekt:mapbox-react-native-mapbox-gl:unspecified' --> 'com.facebook.react:react-native:0.59.6' --> 'com.squareup.okio:okio:1.15.0'
    Dependency path 'projekt:mapbox-react-native-mapbox-gl:unspecified' --> 'com.squareup.okhttp3:okhttp:3.9.1' --> 'com.squareup.okio:okio:1.13.0'
    Dependency path 'projekt:mapbox-react-native-mapbox-gl:unspecified' --> 'com.facebook.react:react-native:0.59.6' --> 'com.squareup.okhttp3:okhttp:3.9.1' --> 'com.squareup.okio:okio:1.13.0'
    Constraint path 'projekt:mapbox-react-native-mapbox-gl:unspecified' --> 'com.squareup.okio:okio' strictly '1.13.0' because of the following reason: debugRuntimeClasspath uses version 1.13.0
    Constraint path 'projekt:mapbox-react-native-mapbox-gl:unspecified' --> 'com.squareup.okio:okio' strictly '1.13.0' because of the following reason: debugRuntimeClasspath uses version 1.13.0
    Constraint path 'projekt:mapbox-react-native-mapbox-gl:unspecified' --> 'com.squareup.okio:okio' strictly '1.13.0' because of the following reason: debugRuntimeClasspath uses version 1.13.0
    Constraint path 'projekt:mapbox-react-native-mapbox-gl:unspecified' --> 'com.squareup.okio:okio' strictly '1.13.0' because of the following reason: debugRuntimeClasspath uses version 1.13.0

> Could not resolve com.squareup.okio:okio:1.13.0.
 Required by:
  project :mapbox-react-native-mapbox-gl > com.squareup.okhttp3:okhttp:3.9.1
> Cannot find a version of 'com.squareup.okio:okio' that satisfies the version constraints:
     Dependency path 'projekt:mapbox-react-native-mapbox-gl:unspecified' --> 'com.facebook.react:react-native:0.59.6' --> 'com.squareup.okio:okio:1.15.0'
     Dependency path 'projekt:mapbox-react-native-mapbox-gl:unspecified' --> 'com.squareup.okhttp3:okhttp:3.9.1' --> 'com.squareup.okio:okio:1.13.0'
     Dependency path 'projekt:mapbox-react-native-mapbox-gl:unspecified' --> 'com.facebook.react:react-native:0.59.6' --> 'com.squareup.okhttp3:okhttp:3.9.1' --> 'com.squareup.okio:okio:1.13.0'
     Constraint path 'projekt:mapbox-react-native-mapbox-gl:unspecified' --> 'com.squareup.okio:okio' strictly '1.13.0' because of the following reason: debugRuntimeClasspath uses version 1.13.0
     Constraint path 'projekt:mapbox-react-native-mapbox-gl:unspecified' --> 'com.squareup.okio:okio' strictly '1.13.0' because of the following reason: debugRuntimeClasspath uses version 1.13.0
     Constraint path 'projekt:mapbox-react-native-mapbox-gl:unspecified' --> 'com.squareup.okio:okio' strictly '1.13.0' because of the following reason: debugRuntimeClasspath uses version 1.13.0
     Constraint path 'projekt:mapbox-react-native-mapbox-gl:unspecified' --> 'com.squareup.okio:okio' strictly '1.13.0' because of the following reason: debugRuntimeClasspath uses version 1.13.0

我尝试了在网络上找到的解决方案,但没有任何效果。

这是我的build.gradle文件:

buildscript {
ext {
    minSdkVersion = 26
    compileSdkVersion = 28
    targetSdkVersion = 28
    supportLibVersion = "28.0.0"
}

repositories {
    google()
    jcenter()
}

dependencies {
    classpath 'com.android.tools.build:gradle:3.3.1'

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}
}

allprojects {
repositories {
    configurations.all { resolutionStrategy { force "com.squareup.okhttp3:okhttp:3.9.1" } } 
    mavenLocal()
    google()
    jcenter()
    maven {
        // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
        url "$rootDir/../node_modules/react-native/android"
    }
 }
}

我尝试了很多事情:抑制node_modules和npm安装,清理缓存,重新启动所有...我确定这是一个本机版本的问题,但是我很新手,我不了解如何修复com.squareup的特定版本。

我什至不知道我是否必须为该项目修复com.squareup的15或13版本。降级反应本机版本不讨我喜欢,我尝试了并且什么都没有改变。我在安装时遇到了很多错误,现在,我在这一步被阻止。这非常令人沮丧,因为这会停止我的项目。

您有个主意吗?

谢谢您的帮助。

1 个答案:

答案 0 :(得分:1)

在您的app/build.gradle中尝试一下,我曾经遇到过这个问题...

compile (project(':@mapbox_react-native-mapbox-gl')) {
    compile ('com.squareup.okhttp3:okhttp:3.6.0') {
        force = true
    }
}

我的root build.gradle(忽略版本号,显然我已经有一段时间没有更新这个项目了)看起来像:

buildscript {
    repositories {
        jcenter()
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.3'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        mavenLocal()
        jcenter()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url "$rootDir/../node_modules/react-native/android"
        }
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
    }
}

更新

由于OP无法创建构建,因此我创建了一个-这就是我的操作方式。问题是(我也遇到过)当您从github存储库Read Me中使用npm install时,由于某种原因,它没有从NPM安装正确的SDK版本。因此,我们必须纠正package.json才能从GH网址强制安装

https://github.com/nitaliano/react-native-mapbox-gl/issues/1602

运行:

react-native init MyProject

转到:package.json并添加相关性(在顶部):

"@mapbox/react-native-mapbox-gl": "https://github.com/nitaliano/react-native-mapbox-gl.git"

运行

npm install

react-native link

react-native run-android