Not able to use capacitor community plugins

Hey Everyone!

I am trying to add capacitor community plugins to my project but for some reason I keep getting the following error: package com.capacitor.rateApp does not exist

This is my “MainActivity.java” file


import android.os.Bundle;

import com.getcapacitor.BridgeActivity;
import com.getcapacitor.Plugin;

import com.capacitor.rateApp.CapacitorRateApp;

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(CapacitorRateApp.class);
    }});
  }
}

Make sure you have done the following steps in your project file:

  • npm i capacitor-rate-app
  • npx cap sync

Now open your android platform project (npx cap open android) and see if that solved your issue, if not please reply.

There is a trick to resolve the import package.

Step1: Open app in android studio, delete import statement.

Step2: goto code their uses and click shortcut: Alt + Shift + Enter / Alt + Enter