React-native-push-notification: 2.2 build failure - android - com.facebook.react.ReactApplication cannot find symbol

Created on 1 Nov 2016  路  9Comments  路  Source: zo0r/react-native-push-notification

Something must've changed

ReactInstanceManager mReactInstanceManager = ((ReactApplication)getApplication()).getReactNativeHost().getReactInstanceManager();

node_modules/react-native-push-notification/android/src/main/java/com/dieam/reactnativepushnotification/modules/RNPushNotificationListenerService.java:11: error: cannot find symbol
import com.facebook.react.ReactApplication;

Cleaned cache and all

I've attempted to fix it by adding path to react native in build.gradle

nothing

thank you

Most helpful comment

This worked for me (as suggested above):

in build.gradle:

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

All 9 comments

I was having the same problem and the suggested change to the maven closure in this issue resolved the problem for me: wix/react-native-navigation#314

Appreciate that @cmmouritsen , its strange that some of the libs such as this one use RN 17+ and then it ends up being cached with m2 repository path

So you added this

maven {
url "$rootDir/../node_modules/react-native/android"
}

to build to RN push notifications's build.gradle

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

should i replace jcenter() with that line?

thanks

No. In the build.gradle file in the root of the android directory of my project, I changed
maven { // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm url "$projectDir/../../node_modules/react-native/android" }
to
maven { // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm url "$rootDir/../node_modules/react-native/android" }

This worked for me (as suggested above):

in build.gradle:

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

this does not work when building RN from source. cc @npomfret

Hey i strongly recommend leaving this library in favour of FCM (firebased based one, works fine with ios, android)

@chirag04 did you figure out a way to get it working when building from source?
I'm having a nightmare getting my fork to work with react-native-fcm

Nope. I couldn't figure it out. It seems like when building RN from source ReactApplication class is not available which is y it breaks. cc @npomfret

I'm stuck at 2.1.1 which does not have this problem.

I was worried you'd say that! It doesn't make sense - I can build from source as long as the source is from the official repository, just not when it's from my own fork...

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ssolida picture ssolida  路  3Comments

DanDance picture DanDance  路  3Comments

NiuQiaoling picture NiuQiaoling  路  3Comments

nguyenvanphuc2203 picture nguyenvanphuc2203  路  3Comments

GastonEDiaz picture GastonEDiaz  路  3Comments