Capacitor-community / firebase-analytics not working

I have followed the instructions here:

However in Android I am getting the following error in the MainActivity.java:

cannot find symbol class Analytics Plugin

It also says the import is unused.

package nz.co.wekasolutions.nmtbc;

import android.os.Bundle;

import com.getcapacitor.BridgeActivity;
import com.getcapacitor.Plugin;
import com.getcapacitor.community.firebaseanalytics.FirebaseAnalytics;

import java.util.ArrayList;

public class MainActivity extends BridgeActivity {
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Initializes the Bridge
    this.init(savedInstanceState, new ArrayList<Class<? extends Plugin>>() {{
      // Additional plugins you've installed go here
      // Ex: add(TotallyAwesomePlugin.class);
      add(AnalyticsPlugin.class);
    }});
  }
}

I just deleted the android folder and recreated and it solved the issue.
Not an ideal solution but it was a new project.

Now I have the same issue with my next plugin.

com.getcapacitor.community.fcm.FCMPlugin;

Any ideas on how to resolve this? I don’t fancy rebuilding my entire android project each time I add a plugin.

SOLUTION:
I did the following:

ionic build
npx cap sync android
npx cap open android
Build -> Clean Project
File -> Sync Project With Gradle Files
Run
2 Likes

Hello @wekas After I followed the step and got this error, please may you help me?