React-native-firebase: error: RNFirebaseMessaging is not abstract and does not override

Created on 1 Sep 2017  路  11Comments  路  Source: invertase/react-native-firebase

Issue

:react-native-firebase:compileReleaseJavaWithJavac
/Users/gh.mbp974/Documents/DEV_SITE/quizzApp/appv2/quizz/node_modules/react-native-firebase/android/src/main/java/io/invertase/firebase/messaging/RNFirebaseMessaging.java:34: error: RNFirebaseMessaging is not abstract and does not override abstract method onActivityResult(int,int,Intent) in ActivityEventListener
public class RNFirebaseMessaging extends ReactContextBaseJavaModule implements LifecycleEventListener, ActivityEventListener {
^
1 error
Incremental compilation of 2 classes completed in 0.402 secs.
:react-native-firebase:compileReleaseJavaWithJavac FAILED

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':react-native-firebase:compileReleaseJavaWithJavac'.

    Compilation failed; see the compiler error output for details.

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 6.337 secs
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/android-setup.html

Environment

  1. Application Target Platform: ANDROID

  1. Development Operating System: MacosSierra 10.12.6

  1. Build Tools: Android Sdk tools 26.0.2

  1. React Native version: 0.47.2

  1. RNFirebase Version: 2.1.4

  1. Firebase Module: messaging

Most helpful comment

Hi @GH974

Your projects RN version is out-dated, so here's why & how to fix:

Your RN versions ActivityEventListener is looking for the method: onActivityResult(int,int,Intent), which exists on RN versions <0.33:

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

This was then changed in 0.33 to the current implementation of onActivityResult(Activity activity, int requestCode, int resultCode, Intent data).

I think that your gradle is not correctly looking at node_modules for React Native & is instead looking for React Native from the maven repository which is on v0.20.1 (https://search.maven.org/#search%7Cga%7C1%7Cg%3A%22com.facebook.react%22) as they stopped publishing to maven in favour of node_modules.

Make sure your android/build.gradle has the following:

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"
        }
        maven {
            url "https://maven.google.com"
        }
    }
}

All 11 comments

@Salakar how is this erroring? The abstract method has been there for over a year on RN!

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

Is this my question? I don't know.
I install this plugins and follow your doc, and after i try react-native run-android and this error

Nope was asking Salakar!

@GH974 On your terminal, could you run react-native -v please and let us know the version of react-native-cli

Cheers

Oh sorry...

react-native-cli: 2.0.1
react-native: 0.47.2

@GH974 Ta, could you navigate to /node_modules/react-native-firebase/android/src/main/java/io/invertase/firebase/messaging/RNFirebaseMessaging.java

In there, could you check the onActivityResult exists for sanity please (should be at the bottom).

@Override
public void onActivityResult(Activity activity, int requestCode, int resultCode, Intent data) {
// todo hmm?
}

@Override
public void onNewIntent(Intent intent) {
// todo hmm?
Utils.sendEvent(getReactApplicationContext(), "messaging_notification_received", parseIntent(intent));
}

Hi @GH974

Your projects RN version is out-dated, so here's why & how to fix:

Your RN versions ActivityEventListener is looking for the method: onActivityResult(int,int,Intent), which exists on RN versions <0.33:

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

This was then changed in 0.33 to the current implementation of onActivityResult(Activity activity, int requestCode, int resultCode, Intent data).

I think that your gradle is not correctly looking at node_modules for React Native & is instead looking for React Native from the maven repository which is on v0.20.1 (https://search.maven.org/#search%7Cga%7C1%7Cg%3A%22com.facebook.react%22) as they stopped publishing to maven in favour of node_modules.

Make sure your android/build.gradle has the following:

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"
        }
        maven {
            url "https://maven.google.com"
        }
    }
}

I have new error
Could not find com.google.firebase:firebase-ads:11.2.0.
Searched in the following locations:
file:/Users/gh.mbp974/Library/Android/sdk/extras/google/m2repository/com/google/firebase/firebase-ads/11.2.0/firebase-ads-11.2.0.pom
file:/Users/gh.mbp974/Library/Android/sdk/extras/google/m2repository/com/google/firebase/firebase-ads/11.2.0/firebase-ads-11.2.0.jar
file:/Users/gh.mbp974/Documents/DEV_SITE/quizzApp/testQuizz/AwesomeProject/android/sdk-manager/com/google/firebase/firebase-ads/11.2.0/firebase-ads-11.2.0

@GH974 from above screenshot:

image

Yes I added this. thanks its works

Thanks a lot @Ehesp !! It worked like a charm!

Was this page helpful?
0 / 5 - 0 ratings