React-native-image-crop-picker: Can't build on Android

Created on 24 Oct 2017  路  22Comments  路  Source: ivpusic/react-native-image-crop-picker

Version

Tell us which versions you are using:

  • react-native-image-crop-picker v0.18.0
  • react-native v0.49.3

Platform

Tell us to which platform this issue is related

  • Android

Expected behaviour

react-native run-android should start the app in the emulator

Actual behaviour

Build fails.

:react-native-image-crop-picker:generateReleaseSources
:react-native-image-crop-picker:incrementalReleaseJavaCompilationSafeguard UP-TO-DATE
:react-native-image-crop-picker:compileReleaseJavaWithJavac
:react-native-image-crop-picker:compileReleaseJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.).
/Users/johannordberg/Projects/WorkForHire/TryggMat/TryggMatApp/node_modules/react-native-image-crop-picker/android/src/main/java/com/reactnative/ivpusic/imagepicker/PickerModule.java:31: error: cannot find symbol
import com.facebook.react.modules.core.PermissionAwareActivity;
^
symbol: class PermissionAwareActivity
location: package com.facebook.react.modules.core
/Users/johannordberg/Projects/WorkForHire/TryggMat/TryggMatApp/node_modules/react-native-image-crop-picker/android/src/main/java/com/reactnative/ivpusic/imagepicker/PickerModule.java:32: error: cannot find symbol
import com.facebook.react.modules.core.PermissionListener;
^
symbol: class PermissionListener
location: package com.facebook.react.modules.core
/Users/johannordberg/Projects/WorkForHire/TryggMat/TryggMatApp/node_modules/react-native-image-crop-picker/android/src/main/java/com/reactnative/ivpusic/imagepicker/PickerModule.java:49: error: PickerModule is not abstract and does not override abstract method onActivityResult(int,int,Intent) in ActivityEventListener
class PickerModule extends ReactContextBaseJavaModule implements ActivityEventListener {
^
/Users/johannordberg/Projects/WorkForHire/TryggMat/TryggMatApp/node_modules/react-native-image-crop-picker/android/src/main/java/com/reactnative/ivpusic/imagepicker/PickerModule.java:223: error: cannot find symbol
((PermissionAwareActivity) activity).requestPermissions(missingPermissions.toArray(new String[missingPermissions.size()]), 1, new PermissionListener() {
^
symbol: class PermissionListener
location: class PickerModule
/Users/johannordberg/Projects/WorkForHire/TryggMat/TryggMatApp/node_modules/react-native-image-crop-picker/android/src/main/java/com/reactnative/ivpusic/imagepicker/PickerModule.java:223: error: cannot find symbol
((PermissionAwareActivity) activity).requestPermissions(missingPermissions.toArray(new String[missingPermissions.size()]), 1, new PermissionListener() {
^
symbol: class PermissionAwareActivity
location: class PickerModule
/Users/johannordberg/Projects/WorkForHire/TryggMat/TryggMatApp/node_modules/react-native-image-crop-picker/android/src/main/java/com/reactnative/ivpusic/imagepicker/PickerModule.java:685: error: method does not override or implement a method from a supertype
@Override
^
/Users/johannordberg/Projects/WorkForHire/TryggMat/TryggMatApp/node_modules/react-native-image-crop-picker/android/src/main/java/com/reactnative/ivpusic/imagepicker/PickerModule.java:696: error: method does not override or implement a method from a supertype
@Override
^
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
7 errors
:react-native-image-crop-picker:compileReleaseJavaWithJavac FAILED

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':react-native-image-crop-picker:compileReleaseJavaWithJavac'.
    > Compilation failed; see the compiler error output for details.

Most helpful comment

I tried everything suggested here. I had react-native-image-picker too, but I uninstalled it and removed everything mentioned by @gutioliveira, but no luck.

I kept getting the following errors -

MainApplication.java:6: error: package com.reactnative.ivpusic.imagepicker does not exist
import com.reactnative.ivpusic.imagepicker.PickerPackage;
                                          ^
MainApplication.java:36: error: cannot find symbol
            new PickerPackage(),
                ^
  symbol:   class PickerPackage
  location: class MainApplication

Tried uninstalling and re-installing react-native-image-crop-picker. Did npm cache clean --force and gradlew clean. Nothing worked.

Solution

Finally realized that I didn't have the following in my android\app\build.gradle dependencies and added it manually.

dependencies {
     compile project(':react-native-image-crop-picker')
}

I was thinking that react-native link would've resolved it and I spent 5 minutes without even thinking this would be an issue. But anyways, adding it fixed the build error for me and I hope this helps someone. I guess it's probably worth mentioning it in the ReadMe (even though it's fairly obvious).

All 22 comments

Same here @ivpusic

Version

Tell us which versions you are using:

  • react-native-image-crop-picker v0.18.1
  • react-native v0.50.3

+1

RN 0.49.5 and
"react-native-image-crop-picker": "0.18.1"

Same output as original post.

Same with RN 0.50.4

any solutions? I am facing same issue

I cannot reproduce it. Can you guys check example project? That one should build and run successfully. I just tried on the plain new project and didn't get any error.

@ivpusic Could it be related to the way we install our react native package? I was previously using your library and it's been fine. But given that I needed to use adopt a specific commit, I changed my react-native in package.json to point towards a specific branch in a react native repo I forked.

when I removed all node_modules and re-run npm install, then react-native run-android, this happened.

I checked the react-native folder under node_modules, and both PermissionListener.java and PermissionAwareActivity.java are present

Guys I figured out where my issue lies:
I was installing React Native from my own fork. This is essentially building RN from source. If I want this new custom source to be accessed by all my other teammates in git, I have to do this https://facebook.github.io/react-native/docs/android-building-from-source.html#building-for-maven-nexus-deployment and push it to my fork.

Key here is This will package everything that would typically be included in the android directory of your node_modules/react-native/ installation in the root directory of your React Native checkout

The android directory was missing in my case in the folder node_modules/react-native

Experiencing the same problem... :(

+1

@tfsjohan how to solve this problem.

I had the exact same problem. I think who is having this issue also has installed this lbrary https://github.com/react-community/react-native-image-picker.

To solve this issue you must uninstall react-native-image-picker and remove every line that was added on manual installation. After I did this, everything worked just fine.

Files that I removed some imports:

android/app/src/main/java/com/awesomeproject/MainActivity.java

  • import com.imagepicker.permissions.OnImagePickerPermissionsCallback;

android/app/src/main/java/com/awesomeproject/MainApplication.java

  • import com.imagepicker.ImagePickerPackage;

android/settings.gradle

  • include ':react-native-image-picker'
  • project(':react-native-image-picker').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-image-picker/android')

package.json

  • "react-native-image-picker": "^0.26.7"

Does anyone have a resolution? Android will not build for me

Same issue here with latest version (0.19.1) and react-native 0.51.0:

$ react-native run-android
:react-native-image-crop-picker:compileReleaseJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.).
/Users/gianfranco/onova/mobileapp/node_modules/react-native-image-crop-picker/android/src/main/java/com/reactnative/ivpusic/imagepicker/PickerModule.java:31: error: cannot find symbol
import com.facebook.react.modules.core.PermissionAwareActivity;
                                      ^
  symbol:   class PermissionAwareActivity
  location: package com.facebook.react.modules.core
/Users/gianfranco/onova/mobileapp/node_modules/react-native-image-crop-picker/android/src/main/java/com/reactnative/ivpusic/imagepicker/PickerModule.java:32: error: cannot find symbol
import com.facebook.react.modules.core.PermissionListener;
                                      ^
  symbol:   class PermissionListener
  location: package com.facebook.react.modules.core
/Users/gianfranco/onova/mobileapp/node_modules/react-native-image-crop-picker/android/src/main/java/com/reactnative/ivpusic/imagepicker/PickerModule.java:49: error: PickerModule is not abstract and does not override abstract method onActivityResult(int,int,Intent) in ActivityEventListener
class PickerModule extends ReactContextBaseJavaModule implements ActivityEventListener {
^
/Users/gianfranco/onova/mobileapp/node_modules/react-native-image-crop-picker/android/src/main/java/com/reactnative/ivpusic/imagepicker/PickerModule.java:225: error: cannot find symbol
            ((PermissionAwareActivity) activity).requestPermissions(missingPermissions.toArray(new String[missingPermissions.size()]), 1, new PermissionListener() {
                                                                                                                                              ^
  symbol:   class PermissionListener
  location: class PickerModule
/Users/gianfranco/onova/mobileapp/node_modules/react-native-image-crop-picker/android/src/main/java/com/reactnative/ivpusic/imagepicker/PickerModule.java:225: error: cannot find symbol
            ((PermissionAwareActivity) activity).requestPermissions(missingPermissions.toArray(new String[missingPermissions.size()]), 1, new PermissionListener() {
              ^
  symbol:   class PermissionAwareActivity
  location: class PickerModule
/Users/gianfranco/onova/mobileapp/node_modules/react-native-image-crop-picker/android/src/main/java/com/reactnative/ivpusic/imagepicker/PickerModule.java:697: error: method does not override or implement a method from a supertype
    @Override
    ^
/Users/gianfranco/onova/mobileapp/node_modules/react-native-image-crop-picker/android/src/main/java/com/reactnative/ivpusic/imagepicker/PickerModule.java:708: error: method does not override or implement a method from a supertype
    @Override
    ^
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
7 errors
:react-native-image-crop-picker:compileReleaseJavaWithJavac FAILED

FAILURE: Build failed with an exception.

This didn't work:

react-native uninstall react-native-image-crop-picker
react-native install react-native-image-crop-picker

Hiya,
this solved the problem for me ->
https://stackoverflow.com/questions/30114860/multiple-maven-repositories-in-one-gradle-file

Instead of merging the maven url parameter into the already existing maven-entry i had to add a second.

allprojects {
    repositories {
        mavenLocal()
        jcenter()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url "$rootDir/../node_modules/react-native/android"
        }
        maven {
            url "https://jitpack.io"
        }
    }
}

@gutioliveira My situation is actually like yours. But after I uninstalled react-native-image-picker, it's with no luck. I have deleted every line that package added on installation included what you listed. I still stuck on this now.

Ok, I figured it out. In 'android/build.gradle', I was opinionated to modified as follows

allprojects {
    repositories {
        mavenLocal()
        jcenter()
        maven {
            url "$rootDir/../node_modules/react-native/android"
            url "https://jitpack.io"
        }
    }
}

but, it should be

allprojects {
    repositories {
        mavenLocal()
        jcenter()
        maven { url "https://jitpack.io" }
        maven {
            url "$rootDir/../node_modules/react-native/android"
        }
    }
}

I tried everything suggested here. I had react-native-image-picker too, but I uninstalled it and removed everything mentioned by @gutioliveira, but no luck.

I kept getting the following errors -

MainApplication.java:6: error: package com.reactnative.ivpusic.imagepicker does not exist
import com.reactnative.ivpusic.imagepicker.PickerPackage;
                                          ^
MainApplication.java:36: error: cannot find symbol
            new PickerPackage(),
                ^
  symbol:   class PickerPackage
  location: class MainApplication

Tried uninstalling and re-installing react-native-image-crop-picker. Did npm cache clean --force and gradlew clean. Nothing worked.

Solution

Finally realized that I didn't have the following in my android\app\build.gradle dependencies and added it manually.

dependencies {
     compile project(':react-native-image-crop-picker')
}

I was thinking that react-native link would've resolved it and I spent 5 minutes without even thinking this would be an issue. But anyways, adding it fixed the build error for me and I hope this helps someone. I guess it's probably worth mentioning it in the ReadMe (even though it's fairly obvious).

+1

Yup that was it for me - wouldn't this be a bug with the react-native link command that it doesn't add it there?

\android\app\src\main\java\com{project}\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{project}\MainApplication.java:30: error: cannot find symbol
new PickerPackage(),
^
symbol: class PickerPackage
2 errors
:app:compileDebugJavaWithJavac FAILED

my android\app\build.gradle file:
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
}

my android\app\src\main\java\com\perkloanapp\MainApplication.java file:
...
import com.facebook.react.ReactApplication;
import com.reactnative.ivpusic.imagepicker.PickerPackage;
...

public class MainApplication extends Application implements ReactApplication {

private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
@Override
public boolean getUseDeveloperSupport() {
return BuildConfig.DEBUG;
}

@Override
protected List<ReactPackage> getPackages() {
  return Arrays.<ReactPackage>asList(
      new MainReactPackage(),
        new PickerPackage(),
        ...
  );
}

};

@Override
public ReactNativeHost getReactNativeHost() {
return mReactNativeHost;
}

@Override
public void onCreate() {
super.onCreate();
SoLoader.init(this, /* native exopackage */ false);
}
}

+1

tried everything metioned above, still not working

Cross check >> react-native link react-native-image-crop-picker
Run through the post install steps once more. Make sure you have not made any mistakes.
cleanbuild also helps. \android> $gradlew clean

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tximpa91 picture tximpa91  路  3Comments

Phenek picture Phenek  路  3Comments

fmcruz picture fmcruz  路  3Comments

xuchao321 picture xuchao321  路  3Comments

aterribili picture aterribili  路  3Comments