React-native-image-crop-picker: Task "compileDebugJavaWithJavac" fails when building for Android

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

Version

  • react-native-image-crop-picker ^0.20.3
  • react-native ^0.56.0

Platform

  • Android

Expected behaviour

Project compiles and runs on android emulator

Actual behaviour

Project fails when building

Steps to reproduce

  1. create a new react-native project

  2. follow the installation instructions for react-native-image-crop-picker

  3. run "react-native run-android" on terminal

Attachments

This is the error message I get on my terminal after trying to run the project for android:

Task :react-native-image-crop-picker:compileDebugJavaWithJavac FAILED
/Users/gabriel/Repos/selectapp/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.PermissionAwareActivity;
                                      ^
  symbol:   class PermissionAwareActivity
  location: package com.facebook.react.modules.core
/Users/gabriel/Repos/selectapp/node_modules/react-native-image-crop-picker/android/src/main/java/com/reactnative/ivpusic/imagepicker/PickerModule.java:33: error: cannot find symbol
import com.facebook.react.modules.core.PermissionListener;
                                      ^
  symbol:   class PermissionListener
  location: package com.facebook.react.modules.core
/Users/gabriel/Repos/selectapp/node_modules/react-native-image-crop-picker/android/src/main/java/com/reactnative/ivpusic/imagepicker/PickerModule.java:50: error: PickerModule is not abstract and does not override abstract method onActivityResult(int,int,Intent) in ActivityEventListener
class PickerModule extends ReactContextBaseJavaModule implements ActivityEventListener {
^
/Users/gabriel/Repos/selectapp/node_modules/react-native-image-crop-picker/android/src/main/java/com/reactnative/ivpusic/imagepicker/PickerModule.java:231: error: cannot find symbol
            ((PermissionAwareActivity) activity).requestPermissions(missingPermissions.toArray(new String[missingPermissions.size()]), 1, new PermissionListener() {
                                                                                                                                              ^
  symbol:   class PermissionListener
  location: class PickerModule
/Users/gabriel/Repos/selectapp/node_modules/react-native-image-crop-picker/android/src/main/java/com/reactnative/ivpusic/imagepicker/PickerModule.java:231: error: cannot find symbol
            ((PermissionAwareActivity) activity).requestPermissions(missingPermissions.toArray(new String[missingPermissions.size()]), 1, new PermissionListener() {
              ^
  symbol:   class PermissionAwareActivity
  location: class PickerModule
/Users/gabriel/Repos/selectapp/node_modules/react-native-image-crop-picker/android/src/main/java/com/reactnative/ivpusic/imagepicker/PickerModule.java:710: error: method does not override or implement a method from a supertype
    @Override
    ^
/Users/gabriel/Repos/selectapp/node_modules/react-native-image-crop-picker/android/src/main/java/com/reactnative/ivpusic/imagepicker/PickerModule.java:721: 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


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.

This is my android/build.gradle file

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

allprojects {
    repositories {
        google()
        mavenLocal()
        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"
        }
    }
}

And my android/app/build.gradle file:

apply plugin: "com.android.application"

import com.android.build.OutputFile

project.ext.react = [
    entryFile: "index.js"
]

apply from: "../../node_modules/react-native/react.gradle"

def enableSeparateBuildPerCPUArchitecture = false

def enableProguardInReleaseBuilds = false

android {
    compileSdkVersion 27
    buildToolsVersion "27.0.3"

    defaultConfig {
        applicationId "com.selectapp"
        minSdkVersion 18
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        ndk {
            abiFilters "armeabi-v7a", "x86"
        }

        vectorDrawables.useSupportLibrary = true
    }
    splits {
        abi {
            reset()
            enable enableSeparateBuildPerCPUArchitecture
            universalApk false 
            include "armeabi-v7a", "x86"
        }
    }
    buildTypes {
        release {
            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
        }
    }

    applicationVariants.all { variant ->
        variant.outputs.each { output ->
            def versionCodes = ["armeabi-v7a":1, "x86":2]
            def abi = output.getFilter(OutputFile.ABI)
            if (abi != null) {  // null for the universal-debug, universal-release variants
                output.versionCodeOverride =
                        versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
            }
        }
    }
}

dependencies {
    implementation project(':react-native-image-crop-picker')
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation "com.android.support:appcompat-v7:27.0.3"
    implementation "com.facebook.react:react-native:+" 
}

task copyDownloadableDepsToLibs(type: Copy) {
    from configurations.compile
    into 'libs'
}

I have no clue why this is happening, any help would be appreciated. Thank you

All 4 comments

in android/build.gradle, under allprojects/repositories, separate maven repositories like so:

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" }
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
    }
}

same problem, react-native 0.57.3 react-native-image-crop-picker 0.21.2
@SASoto 'separate maven repositories' not work

same problem, react-native 0.57.3 react-native-image-crop-picker 0.21.2
@SASoto 'separate maven repositories' not work

@gabsschneider
I fix this;
it is because i build the react-native by myself,so my project can not find the node_modules/react-native/android directory

i solve this problem by this steps:
check the node_modules/react-native/android directory;
reinstall react-native

if u build the react-native by youself,u should:
1.npm intall the react-native from the npmjs ;
2.then take "android" directory
3.reinstall react-native by you own addr
4.put the "android" directory into the node_modules/react-native/

Was this page helpful?
0 / 5 - 0 ratings