ionic-team / capacitor

Build cross-platform Native Progressive Web Apps for iOS, Android, and the Web ⚑️
https://capacitorjs.com
MIT License
11.5k stars 983 forks source link

bug: Error: <PLUGIN_NAME> plugin is not implemented on android | Browser, Storage, Dialog #4791

Closed ZhymonNorman closed 2 years ago

ZhymonNorman commented 3 years ago

Bug Report

Capacitor Version


πŸ’Š   Capacitor Doctor  πŸ’Š 

Latest Dependencies:

  @capacitor/cli: 3.0.2
  @capacitor/core: 3.0.2
  @capacitor/android: 3.0.2
  @capacitor/ios: 3.0.2

Installed Dependencies:

  @capacitor/cli: 3.0.2
  @capacitor/core: 3.0.2
  @capacitor/android: 3.0.

Platform(s)

Android

Current Behavior

Hi everyone, looking for some assistance with capacitor v3 and plugins for Android, on iOS all the plugins we want to use are working just fine, however with Android I keep getting Msg: Uncaught (in promise) Error: plugin is not implemented on android below is the package json, MainActivity.java and capacitor config. thank you.

MainActivity.java

package org.elevationchurch.Elevation;
import com.getcapacitor.BridgeActivity;
public class MainActivity extends BridgeActivity {
}

Package.json (plugins only, can provide full file if needed)

......
"@capacitor-community/firebase-analytics": "latest",
    "@capacitor-community/native-audio": "^3.0.0",
    "@capacitor/android": "3.0.2",
    "@capacitor/browser": "1.0.2",
    "@capacitor/cli": "3.0.2",
    "@capacitor/core": "3.0.2",
    "@capacitor/dialog": "1.0.1",
    "@capacitor/geolocation": "1.0.2",
    "@capacitor/ios": "3.0.2",
    "@capacitor/local-notifications": "1.0.2",
    "@capacitor/push-notifications": "1.0.2",
    "@capacitor/share": "1.0.2",
    "@capacitor/status-bar": "1.0.2",
    "@capacitor/storage": "1.0.2",
.......

capacitor config

{
  "appId": "org.elevationchurch.Elevation",
  "appName": "capjs-test",
  "bundledWebRuntime": false,
  "plugins": {
    "PushNotifications": {
      "presentationOptions": ["sound", "alert"]
    },
    "LocalNotifications": {
      "sound": "beep.wav",
    }
  },
  "server": {
    "androidScheme": "https",
    "hostname": "live.elevationchurch.online"
  },
  "webDir": "out"
}

logs

2021-07-04 14:35:45.134 7074-7074/org.elevationchurch.Elevation E/Capacitor/Console: File: https://live.elevationchurch.online/_next/static/chunks/pages/_app-7f17bcb3263ca40eb5b1.js - Line 1 - Msg: Uncaught (in promise) Error: "StatusBar" plugin is not implemented on android
2021-07-04 14:35:45.134 7074-7074/org.elevationchurch.Elevation E/Capacitor/Console: File: https://live.elevationchurch.online/_next/static/chunks/pages/_app-7f17bcb3263ca40eb5b1.js - Line 1 - Msg: Uncaught (in promise) Error: "FirebaseAnalytics" plugin is not implemented on android
2021-07-04 14:35:45.134 7074-7074/org.elevationchurch.Elevation E/Capacitor/Console: File: https://live.elevationchurch.online/_next/static/chunks/pages/_app-7f17bcb3263ca40eb5b1.js - Line 1 - Msg: Uncaught (in promise) Error: "PushNotifications" plugin is not implemented on android
2021-07-04 14:35:45.134 7074-7074/org.elevationchurch.Elevation E/Capacitor/Console: File: https://live.elevationchurch.online/_next/static/chunks/pages/_app-7f17bcb3263ca40eb5b1.js - Line 1 - Msg: Uncaught (in promise) Error: "PushNotifications" plugin is not implemented on android
2021-07-04 14:35:45.135 7074-7074/org.elevationchurch.Elevation E/Capacitor/Console: File: https://live.elevationchurch.online/_next/static/chunks/pages/_app-7f17bcb3263ca40eb5b1.js - Line 1 - Msg: Uncaught (in promise) Error: "CapacitorFirebaseDynamicLinks" plugin is not implemented on android
2021-07-04 14:35:45.135 7074-7074/org.elevationchurch.Elevation E/Capacitor/Console: File: https://live.elevationchurch.online/_next/static/chunks/pages/_app-7f17bcb3263ca40eb5b1.js - Line 1 - Msg: Uncaught (in promise) Error: "PushNotifications" plugin is not implemented on android
......
2021-07-04 14:36:10.692 7074-7074/org.elevationchurch.Elevation E/Capacitor/Console: File: https://live.elevationchurch.online/_next/static/chunks/pages/_app-7f17bcb3263ca40eb5b1.js - Line 1 - Msg: Uncaught (in promise) Error: "Storage" plugin is not implemented on android

Expected Behavior

Any core capacitor plugin should be auto registered and work out of the box.

Code Reproduction

# LIB.ts

import { Browser } from '@capacitor/browser';

export async function openCapacitorSite(uri: string) {
  await Browser.open({ url: uri });
}

..........

# CTA.tsx

 <div className="flex justify-center pb-2">
        <button
          onClick={() => {
            openCapacitorSite(Link);
          }}
          className="w-full py-2 mx-3 tracking-wider text-black uppercase border-2 border-gray-400 rounded-md font-heading dark:border-gray-300 dark:text-white"
        >
          {CTA_Text}
        </button>
      </div>

Other Technical Details

node version v14.15.4 nextjs ^10 via next export typescript react js

Ionitron commented 3 years ago

This issue may need more information before it can be addressed. In particular, it will need a reliable Code Reproduction that demonstrates the issue.

Please see the Contributing Guide for how to create a Code Reproduction.

Thanks! Ionitron πŸ’™

qwerty724 commented 3 years ago

Im having same issue here, but with custom plugin (following custom plugin creation tutorial).

Ive tried:

My MainActivity.java is =

public class MainActivity extends BridgeActivity {

  @Override
  public void onCreate(Bundle savedInstanceState){
    super.onCreate(savedInstanceState);
    registerPlugin(com.hmsolutions.cashregisterplugin.CashRegisterPlugin.class);
  }

}
πŸ’Š   Capacitor Doctor  πŸ’Š 

Latest Dependencies:

  @capacitor/cli: 3.0.2
  @capacitor/core: 3.0.2
  @capacitor/android: 3.0.2
  @capacitor/ios: 3.0.2

Installed Dependencies:

  @capacitor/ios: not installed
  @capacitor/cli: 3.0.2
  @capacitor/android: 3.0.2
  @capacitor/core: 3.0.2

Thanks for helping, this is my first post on github.

ZhymonNorman commented 3 years ago

@jcesarmobile just checking for clarification was my code reproduction insufficient?

jcesarmobile commented 3 years ago

yes

ZhymonNorman commented 3 years ago

@jcesarmobile updated

jcesarmobile commented 3 years ago

We need a real app where the issue can be reproduced, check the link ionitron provided about how to create one https://github.com/ionic-team/capacitor/blob/HEAD/CONTRIBUTING.md#creating-a-code-reproduction

ZhymonNorman commented 3 years ago

@jcesarmobile

https://github.com/ZhymonNorman/capactiorjs_bugreport_4791 Froked from https://github.com/mlynch/nextjs-tailwind-ionic-capacitor-starter

package.json

{
  "name": "nextjs-tailwind-capacitor",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "next dev",
    "sync": "next build && next export && yarn run cap sync",
    "build": "next build",
    "start": "next start",
    "export": "next export"
  },
  "dependencies": {
    "@capacitor/android": "3.0.2",
    "@capacitor/cli": "^3.0.2",
    "@capacitor/core": "^3.0.2",
    "@capacitor/ios": "^3.0.2",
    "@ionic/react": "^5.6.11",
    "@ionic/react-router": "^5.6.11",
    "autoprefixer": "^10.2.6",
    "@capacitor/browser": "1.0.2",
    "classnames": "^2.3.1",
    "next": "11.0.1",
    "postcss": "^8.3.5",
    "react": "17.0.2",
    "react-dom": "17.0.2",
    "react-router-dom": "^5.2.0",
    "react-virtuoso": "^1.9.3",
    "tailwindcss": "^2.2.4"
  },
  "devDependencies": {
    "ionicons": "^5.5.2",
    "prettier": "^2.3.2",
    "pullstate": "^1.22.1",
    "react-use-gesture": "^9.1.3",
    "reselect": "^4.0.0"
  }
}

async function openCapacitorSite(uri) { await Browser.open({ url: uri }); }

const Settings = () => { const settings = Store.useState(selectors.getSettings);

return (

Settings Enable Notifications { setSettings({ ...settings, enableNotifications: e.target.checked, }); }} /> URL Test

); };

export default Settings;


- build and run app via Android Studio 
- tap the menu button (top left)
- tap "Settings" button
- Tap the 'URL Test' button (right hand side)
jcesarmobile commented 3 years ago

the sample app you have provided has the init method in MainActivity.java

    // Initializes the Bridge
    this.init(savedInstanceState, new ArrayList<Class<? extends Plugin>>() {{
      // Additional plugins you've installed go here
      // Ex: add(TotallyAwesomePlugin.class);
    }});

Which prevents automatic plugin loading, if you remove it as explained on the upgrade guide then it works Or you can continue using the manual registration by adding add(BrowserPlugin.class); inside the init method

ZhymonNorman commented 3 years ago

Issue appears to be unrelated to plugin registration, thank you for your help.

J4si3k commented 3 years ago

What the hell is going on with this new version of Capacitor? When I started my adventure with the second version, everything went smoothly and beautifully. Plugins cannot be used in the new version! I create a new project and follow the instructions, and the plugins throw errors.

import { LocalNotifications } from '@capacitor/local-notifications'

export default {
  name: 'Settings',
  methods: {
    async getNotification () {
      await LocalNotifications.requestPermission() // localNotifications.requestPermissions is not implemnted on android
      await LocalNotifications.schedule({
        notifications: [
          {
            title: 'Title',
            body: 'Body',
            id: new Date().getTime(),
            schedule: { at: new Date(Date.now() + 1000 * 5) },
            sound: null,
            attachments: null,
            actionTypeId: '',
            extra: null
          }
        ]
      })
    }
  }
}

Also i've got similar error in Device plugin.

ZhymonNorman commented 2 years ago

Still haven’t resolved this on my end either.

stevebrowndotco commented 2 years ago

I'm still getting the error plugin is not implemented on android. I have followed all the advice but I am still getting the error

My MainActivity.java looks like this

package com.ionicframework.chalk208279;

import android.os.Bundle;
import com.getcapacitor.BridgeActivity;
import com.hemangkumar.capacitorgooglemaps.CapacitorGoogleMaps;

public class MainActivity extends BridgeActivity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        registerPlugin(com.getcapacitor.community.facebooklogin.FacebookLogin.class);
        registerPlugin(CapacitorGoogleMaps.class);
    }
}
stevebrowndotco commented 2 years ago

It looks like MainActivity.java is completly being ignored.

Latest Dependencies:

  @capacitor/cli: 3.1.2
  @capacitor/core: 3.1.2
  @capacitor/android: 3.1.2
  @capacitor/ios: 3.1.2

Installed Dependencies:

  @capacitor/cli: 3.1.2
  @capacitor/core: 3.1.2
  @capacitor/android: 3.1.2
  @capacitor/ios: 3.1.2

[success] iOS looking great! πŸ‘Œ
[success] Android looking great! πŸ‘Œ
jcesarmobile commented 2 years ago

In the provided app the problem was the automatic registration not enabled, so please, don't reopen the issue. If you still face the issue after enabling the automatic registration, create a new issue with a new sample app where the automatic registration is enabled but the plugins don't work.