cordova-plugin-background-mode icon indicating copy to clipboard operation
cordova-plugin-background-mode copied to clipboard

Error : "plugin is not installed"

Open almogk012 opened this issue 7 years ago • 7 comments

after i run the code and installed

 ionic cordova plugin add cordova-plugin-background-mode
 npm install --save @ionic-native/background-mode

i get this message error in console when i run the commend 'ionic cordova run android':

Native: tried calling BackgroundMode.enable, but the BackgroundMode plugin is not installed.
Install the BackgroundMode plugin: 'ionic plugin add cordova-plugin-background-mode'

almogk012 avatar Dec 24 '17 14:12 almogk012

same fcking message I've got. Tried everything.... with no luck. And I don't understand why nobody give a fck about it. At least somebody should tell us what is going on or how they set it up

iamisti avatar Jan 17 '18 08:01 iamisti

same thing....has anybody gotten this to work??

ehance avatar Apr 05 '18 17:04 ehance

In my case the background mode is already installed but sometimes when i launch the app the error occurs.

palmeranderan avatar Aug 01 '18 10:08 palmeranderan

Installing "cordova-plugin-background-mode" for android android-sdk version check failed ("/Users/karuppasamy/sites/mc_sales_poc/platforms/android/cordova/android_sdk_version"), continuing anyways. Plugin dependency "[email protected]" already fetched, using that version. Dependent plugin "cordova-plugin-device" already installed on android. Android Studio project detected Adding cordova-plugin-background-mode to package.json Saved plugin info for "cordova-plugin-background-mode" to config.xml Innbuilts-MacBook-Air:mc_sales_poc karuppasamy$ ionic cordova plugin add cordova-plugin-app-update

karuppasami6492 avatar Sep 04 '18 14:09 karuppasami6492

I installed this plugin and its Ionic Native wrapper today and got this exact same issue - or so I thought.

I wrapped every call to the plugin with this.platform.ready().then(() => ...) but still got the following error:

Native: tried calling BackgroundMode.unlock, but the BackgroundMode plugin is not installed.
Install the BackgroundMode plugin: 'ionic plugin add cordova-plugin-background-mode'

Then I realised I was actually successfully calling backgroundMode.enable() without error... it was only unlock(), wakeUp() and a few other methods from the documentation that were throwing that warning. I did some digging through the source code and it turned out those methods simply weren't even implemented in the version of the plugin I was using. This issue was actually already reported over a year ago - the latest semver-tagged version of the package resolved by npm (which cordova plugin add uses under the hood) is out of date.

To fix it, I changed the plugin spec from this:

<plugin name="cordova-plugin-background-mode" spec="^0.7.2" />

to this:

<plugin name="cordova-plugin-background-mode" spec="https://github.com/katzer/cordova-plugin-background-mode.git" />

Hope this helps someone!

chrisfrancis27 avatar Jan 03 '19 17:01 chrisfrancis27

@chrisfrancis27 :sir i executed above commands but i got below error in the console

error: lambda expressions are not supported in -source 1.6 getApp().runOnUiThread(() -> {

kapilSoni101 avatar Aug 21 '19 09:08 kapilSoni101

I managed to fix the problem on my end. Turns out the installation of the plugin was silently failing. Running it on "verbose" mode revealed it: ionic cordova plugin add cordova-plugin-background-mode --verbose

After some digging, I tried the suggestion from Arun Girivasan, in a comment on this answer:

i fix the problem. downgraded cordova cli version. and reinstalled plugin

I was using cordova-cli version 9.0.0, downgraded to 8.1.2, and the plugin was installed successfully. Hope this helps someone.

michelbarbosa avatar Apr 23 '20 17:04 michelbarbosa