Register Capacitor 5+ plugin - examples for MainActivity.java

I’ve been looking into code errors related to registering a plugin in a Capacitor 5+ environment.

From a popular plugin epicshaggy’s capacitor-native-biometric

But this example seems to be related to Capacitor < V5.

import com.epicshaggy.biometric.NativeBiometric;

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

This code shows all sorts of errors, so I was wondering if there exists a strong example of how to do this?

Thanks for reading.

Capacitor 3 introduced automatic plugin registration, you don’t need the init method, plugins should be registered automatically.

But note that the plugin doesn’t support Capacitor 5 yet.

1 Like