React-native-image-crop-picker: error: cannot find symbol import com.reactnative.ivpusic.imagepicker.PickerPackage;

Created on 21 Aug 2018  路  5Comments  路  Source: ivpusic/react-native-image-crop-picker

Version

Tell us which versions you are using:

  • react-native-image-crop-picker v0.21.1
  • react-native v0.55.2

Platform

  • Android

Expected behaviour

Clean Build

Actual behaviour

..\android\app\src\main\java\com\perkloanapp\MainApplication.java:6: error: cannot find symbol
import com.reactnative.ivpusic.imagepicker.PickerPackage;
^
symbol: class PickerPackage
location: package com.reactnative.ivpusic.imagepicker
..\android\app\src\main\java\com\perkloanapp\MainApplication.java:30: error: cannot find symbol
new PickerPackage(),
^
symbol: class PickerPackage
2 errors
:app:compileDebugJavaWithJavac FAILED

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':app:compileDebugJavaWithJavac'.
    > Compilation failed; see the compiler error output for details.

Steps to reproduce

  1. npm i react-native-image-crop-picker --save
  2. react-native link react-native-image-crop-picker
  3. Make sure you are using Gradle >= 2.2.x (android/build.gradle)
  4. VERY IMPORTANT Add the following to your build.gradle's repositories section. (android/build.gradle)
  5. Add useSupportLibrary (android/app/build.gradle)
  6. Use Android SDK >= 26 (android/app/build.gradle)
  7. [Optional] If you want to use camera picker in your project, add following to app\src\main\AndroidManifest.xml

Attachments

Most helpful comment

What I did to get my project to compile is the following:
Add import com.reactnative.ivpusic.imagepicker.PickerPackage; to the top of your Android/app/src/main/java/com/{project name}/MainApplication.java file (if it's not already there), like so,

...
import com.reactnative.ivpusic.imagepicker.PickerPackage;
import java.util.Arrays;
import java.util.List;
...
public class MainApplication extends Application implements ReactApplication {...}

*Disclaimer: Even though my project compiled after doing this, I ran into the error described in #794 *

All 5 comments

What I did to get my project to compile is the following:
Add import com.reactnative.ivpusic.imagepicker.PickerPackage; to the top of your Android/app/src/main/java/com/{project name}/MainApplication.java file (if it's not already there), like so,

...
import com.reactnative.ivpusic.imagepicker.PickerPackage;
import java.util.Arrays;
import java.util.List;
...
public class MainApplication extends Application implements ReactApplication {...}

*Disclaimer: Even though my project compiled after doing this, I ran into the error described in #794 *

My (android/app)build.gradle file has this

dependencies {
compile project(':react-native-image-crop-picker')
compile project(':amazon-cognito-identity-js')
compile project(':react-native-fetch-blob')
compile project(':react-native-vector-icons')
compile fileTree(dir: "libs", include: ["*.jar"])
compile "com.android.support:appcompat-v7:25.0.0"
compile "com.facebook.react:react-native:+" // From node_modules
}

/android/app/src/main/java/com/{projectName}/MainApplication.java file has this...

package com.perkloanapp;

import android.app.Application;

import com.facebook.react.ReactApplication;
import com.reactnative.ivpusic.imagepicker.PickerPackage;
import com.amazonaws.RNAWSCognitoPackage;
import com.RNFetchBlob.RNFetchBlobPackage;
import com.oblador.vectoricons.VectorIconsPackage;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import com.facebook.soloader.SoLoader;

import java.util.Arrays;
import java.util.List;

*My Question is: Where should the package be? - com.reactnative.ivpusic.imagepicker.PickerPackage; *

My solution
I cannot exactly say what worked, but, here is what I did to resolve this...

  1. Deleted the node_module folder.
  2. Deleted all the contents in /project/android/app/build
  3. Deleted /project/android/.gradle folder
  4. Installed npm_module -> $npm install
  5. Run gradle clean -> cd android -> $gradlew clean
  6. finally -> npm run android

What I did to get my project to compile is the following:
Add import com.reactnative.ivpusic.imagepicker.PickerPackage; to the top of your Android/app/src/main/java/com/{project name}/MainApplication.java file (if it's not already there), like so,

...
import com.reactnative.ivpusic.imagepicker.PickerPackage;
import java.util.Arrays;
import java.util.List;
...
public class MainApplication extends Application implements ReactApplication {...}

*Disclaimer: Even though my project compiled after doing this, I ran into the error described in #794 *

Saved my life. Thank you

Adding
implementation project(path: ':react-native-image-crop-picker')
in build.gradle file fixes for me. This line is not provided on their documentation

Was this page helpful?
0 / 5 - 0 ratings