ivpusic / react-native-image-crop-picker

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

Can't build on Android #490

Open tfsjohan opened 6 years ago

tfsjohan commented 6 years ago

Version

Tell us which versions you are using:

Platform

Tell us to which platform this issue is related

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.

eduardojunio commented 6 years ago

Same here @ivpusic

Version

Tell us which versions you are using:

davidck commented 6 years ago

+1

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

Same output as original post.

davidck commented 6 years ago

Same with RN 0.50.4

LEEY19 commented 6 years ago

any solutions? I am facing same issue

ivpusic commented 6 years ago

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.

LEEY19 commented 6 years ago

@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

LEEY19 commented 6 years ago

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

todorone commented 6 years ago

Experiencing the same problem... :(

benniao-chen commented 6 years ago

+1

@tfsjohan how to solve this problem.

gutioliveira commented 6 years ago

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

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

android/settings.gradle

package.json

ghost commented 6 years ago

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

gianpaj commented 6 years ago

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
Psiiirus commented 6 years ago

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"
        }
    }
}
gcmsg commented 6 years ago

@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.

gcmsg commented 6 years ago

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"
        }
    }
}
aswinramakrish commented 6 years ago

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).

Hyman4810 commented 6 years ago

+1

TrekSoft commented 6 years ago

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?

vkandk commented 6 years ago

\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); } }

ParhamZare commented 5 years ago

+1

cbjs commented 5 years ago

tried everything metioned above, still not working

vkandk commented 5 years ago

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

JadenTheGiant commented 2 years ago

Hi, I am able to solve the problem by doing all solutions provided above. Thanks

  1. remove react-native-image-picker library as @gutioliveira steps.
  2. add a dependencies under android\app\build.gradle dependencies { implementation project(':react-native-image-crop-picker') }
  3. change android\build.gradle version from 3.5.3 to 3.5.4 dependencies { classpath("com.android.tools.build:gradle:3.5.4") }

and lastly close everything and restart again.

RanvijayChouhan12 commented 1 year ago

Just DO this in android/build.gradle

buildToolsVersion = "31.0.0"
minSdkVersion = 21
compileSdkVersion = 33
targetSdkVersion = 33