我无法使用react-native-image-crop-picker

时间:2019-08-09 07:47:51

标签: android reactjs react-native

我想添加多个图像上传功能,所以我在项目中安装了react-native-image-crop-picker库,并在README自述文件中进行了操作。

但是当我尝试构建项目时

react-native run-android

我遇到错误。

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':app:preDebugBuild'.
> Could not resolve all task dependencies for configuration ':app:debugRuntimeClasspath'.
   > Could not find com.github.yalantis:ucrop:2.2.2-native.
     Searched in the following locations:
       - file:/C:/Users/mmtbo/.m2/repository/com/github/yalantis/ucrop/2.2.2-native/ucrop-2.2.2-native.pom
       - file:/C:/Users/mmtbo/.m2/repository/com/github/yalantis/ucrop/2.2.2-native/ucrop-2.2.2-native.jar
       - file:/C:/Users/mmtbo/workspace/imagePickertest/node_modules/react-native/android/com/github/yalantis/ucrop/2.2.2-native/ucrop-2.2.2-native.pom
       - file:/C:/Users/mmtbo/workspace/imagePickertest/node_modules/react-native/android/com/github/yalantis/ucrop/2.2.2-native/ucrop-2.2.2-native.jar
       - file:/C:/Users/mmtbo/workspace/imagePickertest/node_modules/jsc-android/dist/com/github/yalantis/ucrop/2.2.2-native/ucrop-2.2.2-native.pom
       - file:/C:/Users/mmtbo/workspace/imagePickertest/node_modules/jsc-android/dist/com/github/yalantis/ucrop/2.2.2-native/ucrop-2.2.2-native.jar
       - https://dl.google.com/dl/android/maven2/com/github/yalantis/ucrop/2.2.2-native/ucrop-2.2.2-native.pom
       - https://dl.google.com/dl/android/maven2/com/github/yalantis/ucrop/2.2.2-native/ucrop-2.2.2-native.jar
       - https://jcenter.bintray.com/com/github/yalantis/ucrop/2.2.2-native/ucrop-2.2.2-native.pom
       - https://jcenter.bintray.com/com/github/yalantis/ucrop/2.2.2-native/ucrop-2.2.2-native.jar
     Required by:
         project :app > project :react-native-image-crop-picker

我找不到关于此错误的很多信息。

这是来自android / build.gradle

    ext {
        buildToolsVersion = "28.0.3"
        minSdkVersion = 16
        compileSdkVersion = 28
        targetSdkVersion = 28
        supportLibVersion = "28.0.0"
    }
    repositories {
        google()
        mavenLocal()
        jcenter()
        maven { url "$rootDir/../node_modules/react-native/android" }

        // ADD THIS
        maven { url 'https://maven.google.com' }

        // ADD THIS
        maven { url "https://jitpack.io" }
    }
    dependencies {
        classpath("com.android.tools.build:gradle:3.4.1")

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

android / app / build.gradle

android {
    compileSdkVersion rootProject.ext.compileSdkVersion

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    defaultConfig {
        applicationId "com.imagepickertest"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode 1
        versionName "1.0"
        vectorDrawables.useSupportLibrary = true
    }

3 个答案:

答案 0 :(得分:1)

您忘了遵循Post-Install的步骤。

您必须将jitpack.io添加到存储库中。

以下是链接:https://github.com/ivpusic/react-native-image-crop-picker#android-1

答案 1 :(得分:0)

您非常重要的是,在android / build.gradle文件中添加以下行

maven { url "https://jitpack.io" }

因此您的android / build.gradle文件应如下图所示

allprojects {
    repositories {
        .......                 //if there are any other modules
        maven { url "https://jitpack.io" }
    }
}

另请参阅文档中的发布步骤并按照步骤进行操作

https://www.npmjs.com/package/react-native-image-crop-picker#android-1

答案 2 :(得分:0)

我遇到了同样的问题,并且可能是最新版本0.35.0的问题。

通过降级为0.34.1版本来解决。

编辑: 我已经找到了解决问题的真正方法。

您应该升级gradle:com.android.tools.build:gradle:4.0.1

Source