wix / react-native-notifications

React Native Notifications
MIT License
3.23k stars 763 forks source link

Error building on Android. #867

Closed dev4bitcoin closed 2 years ago

dev4bitcoin commented 2 years ago

I installed latest version of this library and getting build issue on Android. It is working fine on iOS.

Version:

"react-native": "0.64.3", "react-native-notifications": "^4.3.1",

Freshly installed yesterday and getting this issue.

Here is the error. Anyone have any idea?

Execution failed for task ':react-native-notifications:compileReactNative60DebugJavaWithJavac'. node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/core/ReactAppLifecycleFacade.java:50: error: cannot find symbol return mReactContext.hasActiveReactInstance(); ^ symbol: method hasActiveReactInstance() location: variable mReactContext of type ReactContext

riogrande100 commented 2 years ago

Downgrading to 4.2.4 worked for me.

dev4bitcoin commented 2 years ago

Downgrading to 4.2.4 worked for me.

I downgraded to 4.3.0 and able to build successfully. Now I can see the notification received in console but not in the notification center. Is it working fine on Android?

DanielEliraz commented 2 years ago

starting RN@0.66 they changed the function name. I'll add them both

dev4bitcoin commented 2 years ago

Is that function name change for notification not recieving in Notification Center but able to see in console?

luizppa commented 2 years ago

It did not solved the problem for me in a forked version of this repository (up to date with master) and RN 0.64.2. Using:

@Override
public synchronized boolean isReactInitialized() {
    if (mReactContext == null) {
        return false;
    }

    try {
        return mReactContext.hasActiveCatalystInstance();
    } catch (Exception e) {
        return mReactContext.hasActiveReactInstance();
    }
}

still gave me the same error, I had to change it back to:

@Override
public synchronized boolean isReactInitialized() {
    if (mReactContext == null) {
        return false;
    }

    return mReactContext.hasActiveCatalystInstance();
}

on my fork. PS.: I am not a java developer in any shape form or fashion, it is entirely possible that I did something wrong.

Arkan4ik commented 2 years ago

@luizppa have you solved this issue?

luizppa commented 2 years ago

@luizppa have you solved this issue?

Yes, you can check out the result in this fork. It also has some other modifications, so I wouldn't recommend using it without checking the diff to the original repository.

This is the commit specifically.

Arkan4ik commented 2 years ago

@luizppa have you solved this issue?

Yes, you can check out the result in this fork. It also has some other modifications, so I wouldn't recommend using it without checking the diff to the original repository.

This is the commit specifically.

@luizppa yep, I also used it according to deprecation. Seems like need to upgrade react native version for support that method. Thank you for fast response! image

https://github.com/facebook/react-native/blob/main/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactContext.java