未配置 React Native Image Picker

React Native Image Picker not configures

我正在尝试将 react-native-image-picker 安装到我的 React-native 项目中,我已经按照文档的建议进行了配置;如示例所示;我尝试重新安装 Android Studio(3.1 和 3.2);我下载了所有 API 和所有工具;没有解决问题:

Starting JS server...
Building and installing the app on the device (cd android && ./gradlew installDebug)...

> Configure project :app 
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html


FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':react-native-image-picker'.
> Could not resolve all files for configuration ':react-native-image-picker:classpath'.
   > Could not find com.android.tools:common:25.2.3.
     Searched in the following locations:
         https://jcenter.bintray.com/com/android/tools/common/25.2.3/common-25.2.3.pom
         https://jcenter.bintray.com/com/android/tools/common/25.2.3/common-25.2.3.jar
     Required by:
         project :react-native-image-picker > com.android.tools.build:gradle:2.2.3 > com.android.tools.build:gradle-core:2.2.3 > com.android.tools.build:builder:2.2.3
         project :react-native-image-picker > com.android.tools.build:gradle:2.2.3 > com.android.tools.build:gradle-core:2.2.3 > com.android.tools.build:builder:2.2.3 > com.android.tools.build:manifest-merger:25.2.3
         project :react-native-image-picker > com.android.tools.build:gradle:2.2.3 > com.android.tools.build:gradle-core:2.2.3 > com.android.tools.build:builder:2.2.3 > com.android.tools.ddms:ddmlib:25.2.3
         project :react-native-image-picker > com.android.tools.build:gradle:2.2.3 > com.android.tools.build:gradle-core:2.2.3 > com.android.tools.build:builder:2.2.3 > com.android.tools.analytics-library:shared:25.2.3
         project :react-native-image-picker > com.android.tools.build:gradle:2.2.3 > com.android.tools.build:gradle-core:2.2.3 > com.android.tools.build:builder:2.2.3 > com.android.tools.analytics-library:tracker:25.2.3
         project :react-native-image-picker > com.android.tools.build:gradle:2.2.3 > com.android.tools.build:gradle-core:2.2.3 > com.android.tools.build:builder:2.2.3 > com.android.tools:sdklib:25.2.3 > com.android.tools.layoutlib:layoutlib-api:25.2.3
         project :react-native-image-picker > com.android.tools.build:gradle:2.2.3 > com.android.tools.build:gradle-core:2.2.3 > com.android.tools.build:builder:2.2.3 > com.android.tools:sdklib:25.2.3 > com.android.tools:dvlib:25.2.3
         project :react-native-image-picker > com.android.tools.build:gradle:2.2.3 > com.android.tools.build:gradle-core:2.2.3 > com.android.tools.build:builder:2.2.3 > com.android.tools:sdklib:25.2.3 > com.android.tools:repository:25.2.3

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 1m 9s
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/getting-started.html

我的package.json:

{
  "name": "MyTestApp",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest"
  },
  "dependencies": {
    "moment": "^2.22.2",
    "react": "16.6.1",
    "react-native": "0.57.5",
    "react-native-datepicker": "^1.7.2",
    "react-native-image-picker": "^0.27.1",
    "react-native-loading-spinner-overlay": "^1.0.1",
    "react-native-picker-select": "^5.1.0",
    "react-navigation": "^2.18.2"
  },
  "devDependencies": {
    "babel-jest": "23.6.0",
    "jest": "23.6.0",
    "metro-react-native-babel-preset": "0.49.2",
    "react-test-renderer": "16.6.1"
  },
  "jest": {
    "preset": "react-native"
  }
}

有什么问题吗?

已更新

我的build.graddle

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext {
        buildToolsVersion = "27.0.3"
        minSdkVersion = 16
        compileSdkVersion = 27
        targetSdkVersion = 26
        supportLibVersion = "27.1.1"
    }
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.4'

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

allprojects {
    repositories {
        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"
        }
    }
}


task wrapper(type: Wrapper) {
    gradleVersion = '4.4'
    distributionUrl = distributionUrl.replace("bin", "all")
}

Android 包有自己的构建工具依赖项,这可能会导致这样的错误。最好的解决方案是修改您的 android/build.gradleandroid/app/build.gradle 以覆盖子项目以使用与您的应用程序使用的构建工具相同的构建工具。

android/build.gradle

ext {
    compileSdkVersion = 26
    buildToolsVersion = "26.0.1"
}
buildscript {
    ... Keep this the same ...
}
subprojects { subproject ->
    afterEvaluate{
        if((subproject.plugins.hasPlugin('android') || subproject.plugins.hasPlugin('android-library'))) {
            android {
                compileSdkVersion rootProject.ext.compileSdkVersion
                buildToolsVersion rootProject.ext.buildToolsVersion
            }
        }
    }
}

android/app/build.gradle

android {
    compileSdkVersion rootProject.ext.compileSdkVersion
    buildToolsVersion rootProject.ext.buildToolsVersion

    ... whatever else you have here ...
}

升级到最新版本的 react-native-image-picker(撰写本文时为 0.27.2)似乎可以解决此问题。

Update your all node module package which getting error like "react-native-image-picker" 
open this android project in android studio and update
gradle in individual-individual

dependencies {
    classpath 'com.android.tools.build:gradle:3.2.1'
}

对你有帮助