cordova-plugin-badge icon indicating copy to clipboard operation
cordova-plugin-badge copied to clipboard

Getting error when build app using Cordova

Open aravindforums1 opened this issue 1 year ago • 4 comments

Hi, i am try to add badge count for android app using cordova-plugin-badge, for that i used ShortcutBadger too. i install cordova-plugin-badge ver 0.8.8 , after i add below code in build.gradle and try to build

repositories {
mavenCentral()
}

 if (!project.ext.has('appShortcutBadgerVersion')) {
 ext.appShortcutBadgerVersion = '1.1.22'
 }

 if (!project.ext.has('appShortcutBadgerCustom')) {
 dependencies {
 //compile "me.leolin:ShortcutBadger:${appShortcutBadgerVersion}@aar"
 implementation "me.leolin:ShortcutBadger:${appShortcutBadgerVersion}@aar"
 }
 }

First i get error for Could not find method compile() for arguments , then i replace compile to implementation still getting error.

Below is the error when build

  • What went wrong: A problem occurred evaluating root project 'badge'.

Could not find method implementation() for arguments [me.leolin:ShortcutBadger:1.1.22@aar] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

Note: Before add ShortcutBadger , i can build and install apk file in android phone, that time i added below code in index.js

   if (cordova.plugins.notification.badge.isActivated) {
     alert('cordova-plugin-badge is active');
     console.log('cordova-plugin-badge is active');
     cordova.plugins.notification.badge.set(10);
     } else {
     alert('cordova-plugin-badge is NOT active');
     console.log('cordova-plugin-badge is NOT active');
     cordova.plugins.notification.badge.set(10);
     }

When i run app in mobile device , i always get 'cordova-plugin-badge is NOT active' , not sure how to activate ? I want to show badge count number instead of dot in app icon, currently i get dot in app icon, in mobile setting there is no option to change notification as Number. In whatsapp and sms i can see three options like "Number" , "Dot" and No Badge. Anything need to add in my project config or gradle ?

Thanks and Regards Aravind

aravindforums1 avatar Apr 06 '23 06:04 aravindforums1

Hi, You should not use 0.8.8 version of the plugin since it is not fixed yet. You could try using https://github.com/moodlemobile/cordova-plugin-badge/releases/tag/0.8.8-moodle.1 - they have added implementation instead of compile, but for some crazy reason, I still get build errors. Maybe it will work for you :)

Or you could use https://github.com/katzer/cordova-plugin-badge/commit/8e870f7f358d9435180f92dba4d2fc3b7f52bb4f - check comments there.

ngarafol avatar Apr 06 '23 21:04 ngarafol

Hi, You should not use 0.8.8 version of the plugin since it is not fixed yet. You could try using https://github.com/moodlemobile/cordova-plugin-badge/releases/tag/0.8.8-moodle.1 - they have added implementation instead of compile, but for some crazy reason, I still get build errors. Maybe it will work for you :)

Or you could use 8e870f7 - check comments there.

Hi, i am getting this error when build

D:\Mobile\badge>cordova build android Discovered plugin "cordova-plugin-badge". Adding it to the project Failed to fetch plugin cordova-plugin-badge@^0.8.10 via registry. Probably this is either a connection problem, or plugin spec is incorrect. Check your connection and plugin name/version/URL. CordovaError: Error: npm: Command failed with exit code 1 Error output: npm ERR! code ETARGET npm ERR! notarget No matching version found for cordova-plugin-badge@^0.8.10. npm ERR! notarget In most cases you or one of your dependencies are requesting npm ERR! notarget a package version that doesn't exist.

npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\bapan\AppData\Local\npm-cache_logs\2023-04-10T04_23_58_200Z-debug-0.log

Regards Aravind

aravindforums1 avatar Apr 10 '23 04:04 aravindforums1

Hi, You should not use 0.8.8 version of the plugin since it is not fixed yet. You could try using https://github.com/moodlemobile/cordova-plugin-badge/releases/tag/0.8.8-moodle.1 - they have added implementation instead of compile, but for some crazy reason, I still get build errors. Maybe it will work for you :)

Or you could use 8e870f7 - check comments there.

Could you please explain , how to add this plugin in mobile project ? i used this line to add plugin, cordova plugin add @moodlehq/[email protected] but getting error as above

Regards Aravind

aravindforums1 avatar Apr 10 '23 05:04 aravindforums1

@aravindforums1 Check your package.json or package-lock.json file. Maybe inside of them there is mentioned cordova-plugin-badge 0.8.10 version. Or if there is no mention in the files, there is a chance some of your plugins have it listed as dependency and it is being installed on its own. This was my case, so I totally removed mention of cordova-plugin-badge from package*.json files since some other plugin uses it as dependency and installs it.

ngarafol avatar Apr 17 '23 23:04 ngarafol