web-dev-qa-db-fra.com

React Native Image Picker n'est pas configuré

J'essaie d'installer react-native-image-picker dans mon projet natif de React, que j'ai configuré comme le suggère la documentation; Comme le suggère l'exemple J'ai essayé de réinstaller Android Studio (3.1 et 3.2); Je télécharge toutes les API et tous les outils; Rien ne résout le problème:

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

Mon 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"
  }
}

Quelque chose ne va pas?

MIS À JOUR

mon 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")
}
2
zerokol

Les packages Android ont leurs propres dépendances des outils de construction, ce qui peut provoquer des erreurs de ce type. La meilleure solution consiste à modifier vos Android/build.gradle et Android/app/build.gradle pour écraser les sous-projets afin qu'ils utilisent les mêmes outils de génération que ceux utilisés par votre application.

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 ...
}
2
AnonymousSB

La mise à niveau vers la dernière version de react-native-image-picker (0.27.2 au moment de la rédaction) semble résoudre ce problème.

0
Bataleon
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'
}

ce sera vous aider.

0
Vijendra patidar