ivpusic / react-native-image-crop-picker

iOS/Android image picker with support for camera, video, configurable compression, multiple images and cropping
MIT License
6.13k stars 1.56k forks source link

Android build failing - missing build.gradle parameters #124

Closed Proberts closed 7 years ago

Proberts commented 8 years ago

Version

Tell us which versions you are using:

Platform

Expected behaviour

"react-native run-android" should build react-native-image-crop-picker and dependencies (ucrop)

Actual behaviour

Error: Width (0) and height (0) cannot be < = 0." on file res/drawable/ucrop_vector_loader.xm

Steps to reproduce

  1. rnpm install react-native-image-picker

  2. add PickerPackage lines to MainApplicaiton.java

  3. react-native run-android

Solution

Per [https://github.com/Yalantis/uCrop/issues/84](this ucrop issue), react-native-image-picker/android/build.gradle needs two additions. in defaultConfig{} add:

generatedDensities = []

and under android{} add:

aaptOptions {
  additionalParameters "--no-version-vectors"
}

(These two also need to be added to the RN app's android/app/build.gradle)

i.e. react-native-image-crop-picker/android/build.gradle should look like:

apply plugin: 'com.android.library'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.3"

    defaultConfig {
        minSdkVersion 16
        targetSdkVersion 23
        versionCode 1
        generatedDensities = []
    }
    lintOptions {
        abortOnError false
    }

    aaptOptions {
      additionalParameters "--no-version-vectors"
    }
}

dependencies {
    compile 'com.facebook.react:react-native:+'
    compile 'com.yalantis:ucrop:2.2.0-native'
}
ivpusic commented 8 years ago

I am using Gradle 2.14.1 and cannot reproduce this. Are you using older version or?

Proberts commented 8 years ago

I'm using Gradle 2.4 (installed by React Native.)

grubstarstar commented 7 years ago

I just experienced this too using 2.4.

indesignlatam commented 7 years ago

I added vectorDrawables.useSupportLibrary = true to defaultConfig{}. Im using gradle 2.2.3

defaultConfig {
    ...
    vectorDrawables.useSupportLibrary = true
}
ivpusic commented 7 years ago

@Proberts please check updated android post-install instructions. it should solve your problem