最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

java - Why does Capacitor official plugin not implement OnDestroy? - Stack Overflow

programmeradmin1浏览0评论

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'
  • CapacitorCookies
  • CapacitorHttp
  • WebView
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.

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'
  • CapacitorCookies
  • CapacitorHttp
  • WebView
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.

Share Improve this question asked Feb 6 at 8:21 jared_hexagonjared_hexagon 1811 gold badge1 silver badge15 bronze badges
Add a comment  | 

1 Answer 1

Reset to default -1

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.

发布评论

评论列表(0)

  1. 暂无评论