MapBox 反应本机:'Could not resolve com.squareup.okio:okio:1.13.0'

MapBox React Native : 'Could not resolve com.squareup.okio:okio:1.13.0'

我尝试安装: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 安装,清理缓存,重新启动所有...我确定这是一个 react-native 版本问题,但我对 gradle 而且我不明白如何修复 com.squareup.

的特定版本

我什至不明白我是否必须为该项目修复 com.squareup 的版本 15 或 13。降级 React Native 版本并不令我满意,我试过了但没有任何改变。我在安装时有更多的错误行,现在,我在这一步被阻止了。这非常令人沮丧,因为它此时停止了我的项目。

你有想法吗?

感谢您的帮助。

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

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

我的根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 无法创建构建,我创建了一个 - 我就是这样做的。问题是(我也在 运行ning 中)当你使用 github repo Read Me 中的 npm install 时,它出于某种原因没有从 NPM 安装正确的 SDK 版本。因此我们必须纠正 package.json 以强制从 GH url

安装

(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