arnesson / cordova-plugin-firebase

Cordova plugin for Google Firebase
http://arnesson.github.io/cordova-plugin-firebase
MIT License
1k stars 1.55k forks source link

error: cannot find symbol import com.google.firebase.iid.FirebaseInstanceIdService #1092

Open Imam-N opened 4 years ago

Imam-N commented 4 years ago

My Config : Project/build.gradle

buildscript { repositories { maven { url "https://maven.google.com" } jcenter() google() } dependencies {

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
    classpath 'com.android.tools.build:gradle:3.4.2'
    classpath 'com.google.gms:google-services:4.1.0'
}
configurations.all { resolutionStrategy { force 'com.android.support:support-v4:24.0.0' }}

}

app/build.gradle

dependencies { implementation fileTree(dir: 'libs', include: '*.jar') // SUB-PROJECT DEPENDENCIES START implementation(project(path: ":CordovaLib")) compile "com.google.firebase:firebase-core:+" compile "com.google.firebase:firebase-messaging:+" compile "com.google.firebase:firebase-crash:+" compile "com.google.firebase:firebase-config:+" compile 'com.google.firebase:firebase-auth:16.+' // SUB-PROJECT DEPENDENCIES END }

CompileSDKVersion 28 Error in Console 👍

image

My SDK : image

vgmcglaughlin commented 4 years ago

@Imam-N I had the same issue, was resolved by updating my dependencies as described here: https://github.com/arnesson/cordova-plugin-firebase/issues/1057#issuecomment-490000068

neogucky commented 4 years ago

@vgmcglaughlin That's really just a workaround though.

Also I get a new error: com.google.firebase-iid is being requested by various other libraries at [[17.1.1, 17.1.1]], but resolves to 19.0.0

I'm currently trying to fix that as well but since we are talking about integrating a maintained google plugin there should be some stable solution.

benengi commented 4 years ago

I have the same issue. after all the test , keep having the same error \src\main\java\org\apache\cordova\firebase\FirebasePluginInstanceIDService.java:6: error: cannot find symbol import com.google.firebase.iid.FirebaseInstanceIdService; ^ symbol: class FirebaseInstanceIdService location: package com.google.firebase.iid

fitkannadiga commented 4 years ago

Same error. I am unable to build my project due to this. Did anyone find any solution to this?

Thanks in advance..

baiden commented 4 years ago

FirebaseInstanceIdService is deprecated.

The new approach is to use FirebaseMessagingService.

Sample Code

public class MyFirebaseMessagingService extends FirebaseMessagingService {
    @Override
    public void onNewToken(String s) {
        super.onNewToken(s);
        Log.e("NEW_TOKEN",s);
    }

    @Override
    public void onMessageReceived(RemoteMessage remoteMessage) {
        super.onMessageReceived(remoteMessage);
    }
} 

Add this to the Manifest file:

<service
        android:name=".MyFirebaseMessagingService"
        android:stopWithTask="false">
        <intent-filter>
            <action android:name="com.google.firebase.MESSAGING_EVENT" />
        </intent-filter>
</service>

Read more from here

sgiraldo commented 4 years ago

FirebaseInstanceIdService is deprecated.

The new approach is to use FirebaseMessagingService.

Sample Code

public class MyFirebaseMessagingService extends FirebaseMessagingService {
    @Override
    public void onNewToken(String s) {
        super.onNewToken(s);
        Log.e("NEW_TOKEN",s);
    }

    @Override
    public void onMessageReceived(RemoteMessage remoteMessage) {
        super.onMessageReceived(remoteMessage);
    }
} 

Add this to the Manifest file:

<service
        android:name=".MyFirebaseMessagingService"
        android:stopWithTask="false">
        <intent-filter>
            <action android:name="com.google.firebase.MESSAGING_EVENT" />
        </intent-filter>
</service>

Read more from here

Hi, I'm quite newbie building apps and I'm getting the same error here. How do I exactly fix the issue? Is it editing some file? Where do I find the Manifest file?

Thanks!