Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Execution failed for task ':react-native-image-crop-picker:compileDebugJavaWithJavac' #1098

Open
fahdjamy opened this issue Aug 20, 2019 · 21 comments

Comments

@fahdjamy
Copy link

Version

  • react-native-image-crop-picker v^0.25.0
  • react-native v^0.59.8

Platform

  • Android

Expected behavior

Expecting it to build successfully and I start the implementation

Actual behavior

It is not building and it is throwing an error in the terminal. See attached code and the error that is being thrown.

Please Note.

  • I have done everything that was defined in the Readme.md
  • I have also checked out all related issues but no solution worked for me.

Attachments

my android/build.gradle

buildscript {
  repositories {
    google()
    mavenLocal()
    mavenCentral()
    jcenter()
  }
  dependencies {
    classpath 'com.android.tools.build:gradle:3.4.2'

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
    // classpath 'com.google.gms:google-services:3.2.0'
  }
}

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

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

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

ext {
  buildToolsVersion = "28.0.3"
  minSdkVersion = 18
  compileSdkVersion = 28
  targetSdkVersion = 28
  supportLibVersion = "28.0.0"
}

subprojects { subproject ->
  afterEvaluate {
    if ((subproject.plugins.hasPlugin('android') || subproject.plugins.hasPlugin('android-library'))) {
      android {
        variantFilter { variant ->
          def names = variant.flavors*.name
          // To check for a certain build type, use variant.buildType.name == "<buildType>"
          if (names.contains("reactNative51") || names.contains("reactNative55")) {
            // Gradle ignores any variants that satisfy the conditions above.
            setIgnore(true)
          }
        }
      }
    }
  }
}

Error that is thrown in the terminal

> rn_c@0.0.1 android /Users/fahadasiimwe/projects/native/rn_c
> react-native run-android

info Starting JS server...
info Building and installing the app on the device (cd android && ./gradlew app:installDebug)...

> Configure project :react-native-navigation
downloadRobolectricDependencies into /Users/fahadasiimwe/projects/native/rn_c/android/build/robolectric-3.5.1-dependencies

> Task :react-native-image-crop-picker:compileDebugJavaWithJavac FAILED
/Users/fahadasiimwe/projects/native/rn_c/node_modules/react-native-image-crop-picker/android/src/main/java/com/reactnative/ivpusic/imagepicker/PickerModule.java:20: error: package androidx.core.app does not exist
import androidx.core.app.ActivityCompat;
                        ^
/Users/fahadasiimwe/projects/native/rn_c/node_modules/react-native-image-crop-picker/android/src/main/java/com/reactnative/ivpusic/imagepicker/PickerModule.java:21: error: package androidx.core.content does not exist
import androidx.core.content.FileProvider;
                            ^
/Users/fahadasiimwe/projects/native/rn_c/node_modules/react-native-image-crop-picker/android/src/main/java/com/reactnative/ivpusic/imagepicker/PickerModule.java:228: error: cannot find symbol
            int status = ActivityCompat.checkSelfPermission(activity, permission);
                         ^
  symbol:   variable ActivityCompat
  location: class PickerModule
/Users/fahadasiimwe/projects/native/rn_c/node_modules/react-native-image-crop-picker/android/src/main/java/com/reactnative/ivpusic/imagepicker/PickerModule.java:316: error: cannot find symbol
                mCameraCaptureURI = FileProvider.getUriForFile(activity,
                                    ^
  symbol:   variable FileProvider
  location: class PickerModule
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
4 errors

FAILURE: Build failed with an exception.

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

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.1.1/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 1s
19 actionable tasks: 1 executed, 18 up-to-date
error Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/getting-started.html
error Command failed: ./gradlew app:installDebug. Run CLI with --verbose flag for more details.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! rn_c@0.0.1 android: `react-native run-android`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the rn_c@0.0.1 android script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/fahadasiimwe/.npm/_logs/2019-08-20T09_45_53_106Z-debug.log

Love react-native-image-crop-picker? Please consider supporting our collective:
👉 https://opencollective.com/react-native-image-crop-picker/donate

@gavrilin-remote
Copy link

The same issue.

@gavrilin-remote
Copy link

@fahdjamy
Copy link
Author

Ohh, I have just tried it out right now @gavrilin-remote but I am still getting the same error.
Do you mind elaborating more on how you made it work for you.

@gavrilin-remote
Copy link

gavrilin-remote commented Aug 20, 2019

Firstly I setup project for use androidX and x64 bits support.
"react-native": "0.59.9", "react-native-image-crop-picker": "^0.21.1",

You can find guides for upgrading react-native and enabling x64 bits support in google.

add to gradle.properties:
android.useAndroidX=true android.enableJetifier=true

app/build.gradle:
dependencies {
...
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "androidx.appcompat:appcompat:1.0.0"
implementation "com.facebook.react:react-native:+" // From node_modules
}
then I do:
yarn add jetifier
npx jetifier
react-native run-android

@fahdjamy
Copy link
Author

Thanks a lot, @gavrilin-remote, This truly helped. My app builds successfully.

@VictorTorrens
Copy link

VictorTorrens commented Aug 22, 2019

I have the same issue as the OP, and the workaround of @gavrilin-remote doesnt work for me

@vivek-aecor
Copy link

The same issue.

@mkamals
Copy link

mkamals commented Sep 10, 2019

If you are using react-native version < 0.60 and your app doesn't support androidx then you should probably downgrade this library version to 0.24.1 and try running your application.

@vivek-aecor
Copy link

@mkamals I'm using react-native 57.7 version

@dinu7259
Copy link

dinu7259 commented Sep 22, 2020

same issue....
"react-native": "0.63.2",
"react-native-image-crop-picker": "^0.35.0"

@FMaz008
Copy link

FMaz008 commented Dec 21, 2020

Same problem. Jetifier does not solve the issue.
react-native-image-crop-picker 0.21.1

@andreeadociu
Copy link

This solved the issue for me

brew install android-platform-tools
export JAVA_HOME=/Applications/Android\ Studio.app/Contents/jre/jdk/Contents/Home
yes | ~/Library/Android/sdk/tools/bin/sdkmanager --licenses

@SewaB
Copy link

SewaB commented Dec 14, 2022

RN 0.62.2 same error with the latest version (0.39.0)
Downgrade to v.0.38.0 helped

@ShahAashka
Copy link

RN 0.62.2 same error with the latest version (0.39.0) Downgrade to v.0.38.0 helped

This helped. Thanks.

@vikrvm
Copy link

vikrvm commented Dec 21, 2022

RN 0.62.2 same error with the latest version (0.39.0) Downgrade to v.0.38.0 helped

Downgrading to version 0.38.0 fixed my issue. I'm currently using React Native 0.70.6.

@faijan22
Copy link

@SewaB , it worked for me too, thanks, my react native version is "react-native": "0.70.6", and "react-native-image-crop-picker": was => "^0.39.0", which then i changed to ^0.38.0.

@ERRE216
Copy link

ERRE216 commented Dec 29, 2022

@SewaB , it worked for me too, thanks, my react native version is "react-native": "0.70.6", and "react-native-image-crop-picker": was => "^0.39.0", which then i changed to ^0.38.0.

Same here

@capaj
Copy link

capaj commented Jan 12, 2023

downgrade ti 0.38 helped me too. Why is 0.39 even published? They should revert that change and publish 0.38 as 0.40. Is there anyone for whom 0.39 works?

@M-HARIS-97
Copy link

If you use RN "0.68.2", use react-native-image-crop-picker version "^0.37.3". It works fine in my project

@dakshshah96
Copy link

For all those facing this issue, this PR has the solution for it: #1887.

In my Expo project which I'm building using EAS Build, changing the Android SDK version fixed this. In my app.json file under plugins:

[
	"expo-build-properties",
		{
			"android": {
				"compileSdkVersion": 33,
				"targetSdkVersion": 33,
				"buildToolsVersion": "31.0.0"
			}
		}
]

@junior-jornada
Copy link

If you use RN "0.68.2", use react-native-image-crop-picker version "^0.37.3". It works fine in my project

Working for me <<< I have using react native 0.70

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests