Search code examples
androidandroid-studiocapacitorcapacitor-plugin

Newly Generated Capacitor Plugin Java Import Errors


I'm trying to create my first Capacitor Plugin for an Ionic app. I used the command

npm init @capacitor/plugin

to generate it. Then following the instructions here I opened the android folder in Android Studio. My file though has several import errors that I can't figure out how to fix.

enter image description here

Hovering the red text I get the error:

Cannot resolve symbol 'JSObject'

I haven't changed anything from the generated version. I've tried Invalidating Caches and Restarting as well as Clean Project. I have very little experience in Java and creating Andriod Apps. All I know is there there is an import error, but why if the plugin is freshly generated?


Solution

  • You are following capacitor 3 docs but testing on a capacitor 2 project