jared_hexagon
jared_hexagon

Reputation: 181

Why does Capacitor official plugin not implement OnDestroy?

I am on Ionic Capacitor 6.2.0 (via node_module) and when I build in Android Studio Ladybug (macOS) I am getting an error that the official plugins are not implementing the parent Plugin method correctly:

Class 'CapacitorHttp' must either be declared abstract or implement abstract method 'onDestroy()' in 'Plugin'
public class CapacitorHttp extends Plugin {
  ...
}
public abstract class Plugin {
   ...

   protected abstract void onDestroy();
}

Both classes come from the same 6.2.0 package:

{
  "name": "@capacitor/android",
  "version": "6.2.0",
  "description": "Capacitor: Cross-platform apps with JavaScript and the web",
  ...
}
mypackage % java --version
openjdk 17.0.13 2024-10-15
OpenJDK Runtime Environment Homebrew (build 17.0.13+0)
OpenJDK 64-Bit Server VM Homebrew (build 17.0.13+0, mixed mode, sharing)

Why is this happening? I cannot implement this method myself as it comes from a 3rd party.

Upvotes: -1

Views: 27

Answers (1)

Gabe Sechan
Gabe Sechan

Reputation: 93678

Its an abstract function. That means you have to define it when you extend the class. That can be a no-op implementation if that's all you need, but you need to define it. Why is it abstract? Because the base class can't possibly know what you need to do to properly shutdown.

Upvotes: -1

Related Questions