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)
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-nativeascompile "com.facebook.react:react-native:+" // From node_modulesis what is present in thebuild.gradlein theandroiddirectory. If you notice, in your react-native application, you have two build.gradle files, one inandroid/appdirectory which is the build.gradle for your app and one inandroiddirectory 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-nativeurl "$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, mainlyto 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
ActivityEventListenerinterface 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.