question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

cannot compile this project: "cannot find symbol import com.facebook.react.bridge.BaseActivityEventListener"

See original GitHub issue

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?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:15 (14 by maintainers)

github_iconTop GitHub Comments

6reactions
varungupta85commented, Nov 10, 2016

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.

0reactions
npomfretcommented, Nov 10, 2016

Aaaargh, the point is THEY ALL COMPILE! And they compile on their own, without an enclosing project. They have a build that works, why is that so controversial?

Read more comments on GitHub >

github_iconTop Results From Across the Web

error: cannot find symbol import com.facebook.react.bridge ...
2.patch file in the project that I don't remember adding, so I don't know if that has something to do with it.
Read more >
Android Native Modules
You can find your Android project here within a React Native app: ... import com.facebook.react.bridge.NativeModule;
Read more >
How to fix this error I get when importing kotlin package into ...
I'm building a react native app that uses the ... import com.facebook.react.bridge. ... error: cannot find symbol import com.rncamera0.
Read more >
React-Native Compile Error: Cannot Find Symbol - ADocLib
Solvedreact native firebase RNFirebaseInvites error: cannot find symbol ... cannot compile this project: cannot find symbol import com.facebook.react.bridge ...
Read more >
Native Modules - React Native
Sometimes an app needs access to a platform API that React Native doesn't have a ... ReactContextBaseJavaModule; import com.facebook.react.bridge.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found