react-native-image-picker: cannot compile this project: "cannot find symbol import com.facebook.react.bridge.BaseActivityEventListener"

If i run:

./gradlew clean build

I get:

/Users/nickpomfret/Documents/github/react-native-image-picker/android/src/main/java/com/imagepicker/ImagePickerActivityEventListener.java:6: error: cannot find symbol
import com.facebook.react.bridge.BaseActivityEventListener;
                                ^
  symbol:   class BaseActivityEventListener
  location: package com.facebook.react.bridge

Anyone know what’s going on?

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 15 (14 by maintainers)

Most upvoted comments

hi @marcshilling @npomfret , there has been a lot of discussion on this issue and I thought I will share my two cents because I ran into a similar thing with a different project to which I was adding some features and wanted to build it outside of my react-native application to cut down on the time before I find compilation errors and such. I am not an expert in react-native and I think you guys have a far better understanding of the inner workings of react-native than me, so please correct me if I am wrong.

I think the reason that the app compiles fine and these independent modules don’t compile out of the box even though for both, the build.gradle states the dependency on react-native as compile "com.facebook.react:react-native:+" // From node_modules is what is present in the build.gradle in the android directory. If you notice, in your react-native application, you have two build.gradle files, one in android/app directory which is the build.gradle for your app and one in android directory which contains some configuration which gets applied to all the projects. In that build.gradle, we specify the android specific react-native stuff to get from the local copy of react-native url "$rootDir/../node_modules/react-native/android", so it doesn’t even go to maven to get the published copy of react-native. I think if you were to copy over the contents of this build.gradle, mainly

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.1.3'
        classpath 'com.google.gms:google-services:3.0.0' // Needed for Firebase Analytics
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

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"
        }
    }
}

to this modules build.gradle, make sure that the url points to valid relative location (this could reference the react-native module in your app or a forked copy of react-native etc., run gradlew clean and build the project again, it should build. I haven’t tried it with this project but have tried it with others and they build fine after I do the above. I think the reason, other RN modules that you mentioned compiles without any problem is that they are not implementing the ActivityEventListener interface which has changed over time more importantly since react-native 0.21 due to which you don’t see the compilation errors in those projects that you see here.