firebasex error: constructor Builder in class Builder cannot be applied to given types - ionic-framework

I am making an Ionic app and I want to integrate cordova plugin firebase. Unfortunately, this plugin is not maintained anymore so I use a fork: firebasex.
When running "ionic cordova run android", I get the following error:
BUILD FAILED in 43s
C:\[...]\platforms\android\gradlew: Command failed with exit code 1 Error output:
Note: C:\[...]\platforms\android\CordovaLib\src\org\apache\cordova\engine\SystemCookieManager.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
C:\[...]\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePlugin.java:405: error: cannot find symbol
boolean areNotificationsEnabled = notificationManagerCompat.areNotificationsEnabled();
^
symbol: method areNotificationsEnabled()
location: variable notificationManagerCompat of type NotificationManagerCompat
C:\[...]\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginMessagingService.java:204: error: constructor Builder in class Builder cannot be applied to given types;
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this, channelId);
^
required: Context
found: FirebasePluginMessagingService,String
reason: actual and formal argument lists differ in length
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
2 errors
I have tried everything: removing and adding back android platform, use androidx, reinstalling modules etc etc.
Ionic info:
Ionic:
Ionic CLI : 5.2.3 (C:\Users\test\AppData\Roaming\npm\node_modules\ionic)
Ionic Framework : #ionic/angular 4.7.1
#angular-devkit/build-angular : 0.13.9
#angular-devkit/schematics : 7.3.9
#angular/cli : 7.3.9
#ionic/angular-toolkit : 1.5.1
Cordova:
Cordova CLI : 9.0.0 (cordova-lib#9.0.1)
Cordova Platforms : android 8.0.0
Cordova Plugins : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 4.1.1, (and 16 other plugins)
Utility:
cordova-res : 0.6.0
native-run : 0.2.8
System:
Android SDK Tools : 26.1.1 (C:\[...]\AppData\Local\Android\Sdk)
NodeJS : v10.15.3 (C:\Program Files\nodejs\node.exe)
npm : 6.4.1
OS : Windows 10
Cordova version:
9.0.0 (cordova-lib#9.0.1)
Package.json:
{
"name": "myapp",
"version": "1.0.0",
"author": "me",
"homepage": "page.com",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"#angular/common": "^7.2.2",
"#angular/core": "^7.2.2",
"#angular/forms": "^7.2.2",
"#angular/http": "^7.2.2",
"#angular/platform-browser": "^7.2.2",
"#angular/platform-browser-dynamic": "^7.2.2",
"#angular/router": "^7.2.2",
"#ionic-native/base64": "^5.9.0",
"#ionic-native/camera": "^5.9.0",
"#ionic-native/core": "^5.0.0",
"#ionic-native/file": "^5.10.0",
"#ionic-native/file-chooser": "^5.10.0",
"#ionic-native/file-picker": "^5.10.0",
"#ionic-native/file-transfer": "^5.9.0",
"#ionic-native/firebase": "^5.11.0",
"#ionic-native/http": "^5.9.0",
"#ionic-native/ionic-webview": "^5.11.0",
"#ionic-native/media-capture": "^5.0.0",
"#ionic-native/social-sharing": "^5.10.0",
"#ionic-native/splash-screen": "^5.0.0",
"#ionic-native/status-bar": "^5.0.0",
"#ionic-native/streaming-media": "^5.9.0",
"#ionic/angular": "^4.1.0",
"com-badrit-base64": "0.2.0",
"cordova-android": "^8.0.0",
"cordova-plugin-android-support-v4": "^21.0.1",
"cordova-plugin-androidx": "^1.0.2",
"cordova-plugin-androidx-adapter": "^1.1.0",
"cordova-plugin-camera": "^4.0.3",
"cordova-plugin-file": "6.0.1",
"cordova-plugin-file-transfer": "1.7.1",
"cordova-plugin-filechooser": "1.2.0",
"cordova-plugin-filepicker": "1.1.6",
"cordova-plugin-ionic-webview": "4.1.1",
"cordova-plugin-media-capture": "^3.0.3",
"cordova-plugin-streaming-media": "2.2.0",
"cordova-plugin-x-socialsharing": "5.4.7",
"cordova-support-android-plugin": "1.0.1",
"core-js": "^2.5.4",
"es6-promise-plugin": "4.2.2",
"rxjs": "~6.5.1",
"tslib": "^1.9.0",
"zone.js": "~0.8.29"
},
"devDependencies": {
"#angular-devkit/architect": "~0.13.8",
"#angular-devkit/build-angular": "~0.13.8",
"#angular-devkit/core": "~7.3.8",
"#angular-devkit/schematics": "~7.3.8",
"#angular/cli": "^7.3.9",
"#angular/compiler": "~7.2.2",
"#angular/compiler-cli": "~7.2.2",
"#angular/language-service": "~7.2.2",
"#ionic/angular-toolkit": "~1.5.1",
"#types/jasmine": "~2.8.8",
"#types/jasminewd2": "~2.0.3",
"#types/node": "~12.0.0",
"codelyzer": "~4.5.0",
"cordova-plugin-device": "^2.0.2",
"cordova-plugin-ionic-keyboard": "^2.1.3",
"cordova-plugin-splashscreen": "^5.0.2",
"cordova-plugin-statusbar": "^2.4.2",
"cordova-plugin-whitelist": "^1.3.3",
"jasmine-core": "~2.99.1",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~4.1.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.1",
"karma-jasmine": "~1.1.2",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.4.0",
"ts-node": "~8.3.0",
"tslint": "~5.17.0",
"typescript": "~3.1.6"
},
"description": "An Ionic project",
"cordova": {
"plugins": {
"cordova-plugin-whitelist": {},
"cordova-plugin-statusbar": {},
"cordova-plugin-device": {},
"cordova-plugin-splashscreen": {},
"cordova-plugin-ionic-keyboard": {},
"cordova-plugin-file-transfer": {},
"cordova-plugin-camera": {},
"cordova-plugin-streaming-media": {},
"cordova-plugin-media-capture": {},
"com-badrit-base64": {},
"cordova-plugin-filechooser": {},
"cordova-plugin-filepicker": {},
"cordova-plugin-x-socialsharing": {},
"cordova-plugin-file": {},
"cordova-plugin-ionic-webview": {
"ANDROID_SUPPORT_ANNOTATIONS_VERSION": "27.+"
},
"cordova-plugin-android-support-v4": {},
"cordova-plugin-androidx-adapter": {},
"cordova-plugin-androidx": {},
"cordova-plugin-firebasex": {}
},
"platforms": [
"android"
]
}
}
Thanks for helping me.

For clarity and people just like me searching 'firebase-x boolean areNotificationsEnabled = notificationManagerCompat.areNotificationsEnabled();', the answer is #mobiemp 's comment re android v4.
Simply remove it:
# ionic users
ionic cordova plugin remove cordova-plugin-android-support-v4
# cordova users
cordova plugin remove cordova-plugin-android-support-v4
cordova clean android; # flush it out
# then use your run command again, ie
ionic cordova run android -lc --address=0.0.0.0;

you need to remove firebase plugin if it is still there... also you need to update firebasex... it will fix the problem... if it isn't then trying removing some deprecated plugins you will able to find out in which plugin the problem exists...
it is the problem with the plugin the error message indicating that point. the similar problem exists with other plugins and update of the plugin and removing of the plugin fix the error...
here is the reference

Related

Ionic build error Execution failed for task ':app:processDebugGoogleServices'

I am using ionic and cordova in my project but am getting the above error, yet when I try to search online, all the solutions include google firebase, yet I am not using anything from firebase. The project has been building successfully but the error just came from now where.
Here is the error:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:processDebugGoogleServices'.
> File google-services.json is missing. The Google Services Plugin cannot function without it.
Searched Location:
D:\Projects\Twalako\apps\driver\platforms\android\app\src\nullnull\google-services.json
D:\Projects\Twalako\apps\driver\platforms\android\app\src\debug\google-services.json
D:\Projects\Twalako\apps\driver\platforms\android\app\src\nullnullDebug\google-services.json
D:\Projects\Twalako\apps\driver\platforms\android\app\src\nullnull\debug\google-services.json
D:\Projects\Twalako\apps\driver\platforms\android\app\src\debug\nullnull\google-services.json
D:\Projects\Twalako\apps\driver\platforms\android\app\google-services.json
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
Ionic info
Ionic:
Ionic CLI : 6.12.1 (C:\Users\Evans\AppData\Roaming\npm\node_modules\#ionic\cli)
Ionic Framework : #ionic/angular 5.3.2
#angular-devkit/build-angular : 0.1000.8
#angular-devkit/schematics : 10.0.8
#angular/cli : 10.0.8
#ionic/angular-toolkit : 2.3.3
Capacitor:
Capacitor CLI : 2.4.0
#capacitor/core : 2.4.0
Cordova:
Cordova CLI : 10.0.0
Cordova Platforms : android 8.0.0
Cordova Plugins : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 4.2.1, (and 22 other plugins)
Utility:
cordova-res : 0.15.2
native-run (update available: 1.0.0) : 0.2.8
System:
NodeJS : v14.15.4 (C:\Program Files\nodejs\node.exe)
npm : 6.14.10
OS : Windows 10
package.json
{
"name": "driver",
"version": "0.0.1",
"author": "Ionic Framework",
"homepage": "https://ionicframework.com/",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"#agm/core": "^3.0.0-beta.0",
"#angular/common": "~10.0.0",
"#angular/core": "~10.0.0",
"#angular/forms": "~10.0.0",
"#angular/platform-browser": "~10.0.0",
"#angular/platform-browser-dynamic": "~10.0.0",
"#angular/router": "~10.0.0",
"#capacitor/core": "2.4.0",
"#ionic-native/android-permissions": "^5.30.0",
"#ionic-native/app-version": "^5.28.0",
"#ionic-native/badge": "^5.30.0",
"#ionic-native/call-number": "^5.28.0",
"#ionic-native/camera": "^5.28.0",
"#ionic-native/core": "^5.0.0",
"#ionic-native/crop": "^5.28.0",
"#ionic-native/file": "^5.28.0",
"#ionic-native/geolocation": "^5.28.0",
"#ionic-native/google-maps": "^5.5.0",
"#ionic-native/http": "^5.28.0",
"#ionic-native/in-app-browser": "^5.28.0",
"#ionic-native/ionic-webview": "^5.28.0",
"#ionic-native/location-accuracy": "^5.30.0",
"#ionic-native/native-geocoder": "^5.28.0",
"#ionic-native/network": "^5.30.0",
"#ionic-native/sms-retriever": "^5.28.0",
"#ionic-native/splash-screen": "^5.0.0",
"#ionic-native/status-bar": "^5.0.0",
"#ionic/angular": "^5.0.0",
"#ionic/storage": "^2.3.1",
"call-number": "^1.0.1",
"cordova-androidx-build": "^1.0.4",
"cordova-plugin-add-swift-support": "^2.0.2",
"cordova-plugin-advanced-http": "^3.0.1",
"cordova-plugin-android-permissions": "^1.1.2",
"cordova-plugin-app-version": "^0.1.9",
"cordova-plugin-badge": "^0.8.8",
"cordova-plugin-camera": "^4.1.0",
"cordova-plugin-crop": "^0.4.0",
"cordova-plugin-file": "^6.0.2",
"cordova-plugin-geolocation": "^4.0.2",
"cordova-plugin-googlemaps": "git+https://github.com/mapsplugin/cordova-plugin-googlemaps.git#multiple_maps",
"cordova-plugin-inappbrowser": "^4.0.0",
"cordova-plugin-nativegeocoder": "^3.4.1",
"cordova-plugin-network-information": "^2.0.2",
"cordova-plugin-request-location-accuracy": "^2.3.0",
"cordova-plugin-sms-retriever-manager": "^1.0.2",
"cordova-support-android-plugin": "^1.0.2",
"cordova-support-google-services": "^1.4.1",
"cupertino-pane": "git+https://github.com/roman-rr/cupertino-pane.git",
"ionic-selectable": "^4.7.1",
"ng-otp-input": "^1.7.1",
"ngx-ion-simple-mask": "^0.8.8",
"rxjs": "~6.5.5",
"tslib": "^2.0.0",
"zone.js": "~0.10.3"
},
"devDependencies": {
"#angular-devkit/build-angular": "~0.1000.0",
"#angular/cli": "~10.0.5",
"#angular/compiler": "~10.0.0",
"#angular/compiler-cli": "~10.0.0",
"#angular/language-service": "~10.0.0",
"#capacitor/cli": "2.4.0",
"#ionic/angular-toolkit": "^2.3.0",
"#types/googlemaps": "^3.39.13",
"#types/jasmine": "~3.5.0",
"#types/jasminewd2": "~2.0.3",
"#types/node": "^12.11.1",
"codelyzer": "^6.0.0",
"cordova-android": "^8.0.0",
"cordova-plugin-device": "^2.0.2",
"cordova-plugin-ionic-keyboard": "^2.2.0",
"cordova-plugin-ionic-webview": "^4.2.1",
"cordova-plugin-splashscreen": "^5.0.2",
"cordova-plugin-statusbar": "^2.4.2",
"cordova-plugin-whitelist": "^1.3.3",
"jasmine-core": "~3.5.0",
"jasmine-spec-reporter": "~5.0.0",
"karma": "~5.0.0",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage-istanbul-reporter": "~3.0.2",
"karma-jasmine": "~3.3.0",
"karma-jasmine-html-reporter": "^1.5.0",
"protractor": "~7.0.0",
"ts-node": "~8.3.0",
"tslint": "~6.1.0",
"typescript": "~3.9.5"
},
"description": "An Ionic project",
"cordova": {
"plugins": {
"cordova-plugin-whitelist": {},
"cordova-plugin-statusbar": {},
"cordova-plugin-device": {},
"cordova-plugin-splashscreen": {},
"cordova-plugin-ionic-webview": {},
"cordova-plugin-ionic-keyboard": {},
"cordova-plugin-sms-retriever-manager": {
"PLAY_SERVICES_VERSION": "15.0.1"
},
"cordova-plugin-inappbrowser": {},
"cordova-plugin-app-version": {},
"cordova-plugin-camera": {
"ANDROID_SUPPORT_V4_VERSION": "27.+"
},
"cordova-plugin-file": {},
"cordova-plugin-crop": {},
"cordova-plugin-geolocation": {},
"cordova-plugin-nativegeocoder": {},
"mx.ferreyra.callnumber": {},
"cordova-plugin-advanced-http": {},
"cordova-plugin-googlemaps": {},
"cordova-plugin-android-permissions": {},
"cordova-plugin-request-location-accuracy": {
"PLAY_SERVICES_LOCATION_VERSION": "16.+"
},
"cordova-plugin-network-information": {},
"cordova-plugin-badge": {}
},
"platforms": [
"android"
]
}
}
As you are using cordova-support-google-services for Google Play services so you need to add google-service.json file into your root folder.
To get this file logged in into google console (https://console.firebase.google.com/)
Create New Project / Open Existing Project.
Go to Project Setting & Add/Open Android platform.
Download google-service.json file from there.
Screenshot from the google console:
Add downloaded file to your app root directory.
Project view & file on Visual studio:
Hope this will help you to rid out of google service error.
Thanks!

admob plus and ionic results in runtime error (plugin.constructor.getPluginRef is not a function)

I'm trying to implement ionic admob plus in my ionic application. But whenever I try to show the ad I get the following error. This error appears both for a banner as an interstitial ad.
ERROR Error: Uncaught (in promise): TypeError: plugin.constructor.getPluginRef is not a function
TypeError: plugin.constructor.getPluginRef is not a function
at checkAvailability (VM2270 vendor.js:50324)
at callCordovaPlugin (VM2270 vendor.js:50417)
at VM2270 vendor.js:50251
at VM2270 vendor.js:50193
at new t (VM2269 polyfills.js:3)
at tryNativePromise (VM2270 vendor.js:50192)
at getPromise (VM2270 vendor.js:50213)
at wrapOtherPromise (VM2270 vendor.js:50250)
at VM2270 vendor.js:50509
at cordova (VM2270 vendor.js:148098)
at c (VM2269 polyfills.js:3)
at new t (VM2269 polyfills.js:3)
at tryNativePromise (VM2270 vendor.js:50192)
at getPromise (VM2270 vendor.js:50213)
at wrapOtherPromise (VM2270 vendor.js:50250)
at VM2270 vendor.js:50509
at cordova (VM2270 vendor.js:148098)
at Banner.show (VM2270 vendor.js:91387)
at MyApp.webpackJsonp.717.MyApp.showAd (VM2271 main.js:2123)
at VM2271 main.js:2139
My code: for a banner ad:
this.adMob.banner.show({
id: {
android: "ca-app-pub-xxxxxxxxxxxxxxxxx/xxxxxxxxxxxxx",
ios: ""
}
});
My code: for an interstitial ad:
this.adMob.interstitial.load({
id: {
android: "ca-app-pub-xxxxxxxxxxxxxxxxx/xxxxxxxxx",
ios: ""
}
}).then(() => this.adMob.interstitial.show())
both android ad keys are correct.
My package.json:
{
"name": "xxxxxxxxxxxx",
"version": "0.0.1",
"author": "Ionic Framework",
"homepage": "http://ionicframework.com/",
"private": true,
"scripts": {
"clean": "ionic-app-scripts clean",
"build": "ionic-app-scripts build",
"lint": "ionic-app-scripts lint",
"ionic:build": "ionic-app-scripts build",
"ionic:serve": "ionic-app-scripts serve"
},
"dependencies": {
"#angular/cli": "^6.2.9",
"#angular/common": "5.0.3",
"#angular/compiler": "5.0.3",
"#angular/compiler-cli": "5.0.3",
"#angular/core": "5.0.3",
"#angular/forms": "5.0.3",
"#angular/http": "5.0.3",
"#angular/platform-browser": "5.0.3",
"#angular/platform-browser-dynamic": "5.0.3",
"#ionic-native/admob-plus": "^5.17.0",
"#ionic-native/camera": "^5.15.1",
"#ionic-native/core": "^5.15.1",
"#ionic-native/device": "^5.15.1",
"#ionic-native/facebook": "^5.15.1",
"#ionic-native/file": "^5.15.1",
"#ionic-native/file-path": "^5.15.1",
"#ionic-native/file-transfer": "^5.15.1",
"#ionic-native/google-plus": "^5.15.1",
"#ionic-native/splash-screen": "^5.15.1",
"#ionic-native/status-bar": "^5.15.1",
"#ionic/lab": "^1.0.13",
"#ionic/pro": "1.0.20",
"#ionic/storage": "^2.2.0",
"cordova-admob-plus": "^0.32.0",
"cordova-android": "7.0.0",
"cordova-plugin-android-permissions": "^1.0.2",
"cordova-plugin-camera": "^4.1.0",
"cordova-plugin-device": "^2.0.3",
"cordova-plugin-facebook4": "^3.2.0",
"cordova-plugin-file": "^6.0.2",
"cordova-plugin-file-transfer": "^1.7.1",
"cordova-plugin-filepath": "^1.5.6",
"cordova-plugin-googleplus": "^7.0.2",
"cordova-plugin-inappbrowser": "^3.1.0",
"cordova-plugin-ionic-keyboard": "^2.2.0",
"cordova-plugin-ionic-webview": "^1.2.1",
"cordova-plugin-splashscreen": "^5.0.3",
"cordova-plugin-statusbar": "^2.4.3",
"cordova-plugin-whitelist": "^1.3.4",
"cordova-plugin-x-socialsharing": "^5.4.3",
"cordova-sqlite-storage": "^2.6.0",
"es6-promise-plugin": "^4.2.2",
"ionic-angular": "3.9.2",
"ionic-long-press": "^1.5.0",
"ionicons": "3.0.0",
"ng2-cordova-oauth": "0.0.6",
"node-sass": "^4.10.0",
"rxjs": "5.5.2",
"sw-toolbox": "3.6.0",
"zone.js": "0.8.18"
},
"devDependencies": {
"#ionic/app-scripts": "3.2.3",
"core-js": "^2.6.4",
"typescript": "^3.1.4"
},
"description": "An Ionic project",
"cordova": {
"plugins": {
"cordova-sqlite-storage": {},
"cordova-plugin-device": {},
"cordova-plugin-splashscreen": {},
"cordova-plugin-ionic-webview": {},
"cordova-plugin-ionic-keyboard": {},
"cordova-plugin-file-transfer": {},
"cordova-plugin-file": {},
"cordova-plugin-android-permissions": {},
"cordova-plugin-inappbrowser": {},
"cordova-plugin-whitelist": {},
"cordova-plugin-googleplus": {
"REVERSED_CLIENT_ID": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"PLAY_SERVICES_VERSION": "11.8.0"
},
"cordova-plugin-facebook4": {
"APP_ID": "xxxxxxxxxxxxxx",
"APP_NAME": "xxxxxx",
"FACEBOOK_ANDROID_SDK_VERSION": "4.38.1"
},
"cordova-plugin-statusbar": {},
"cordova-plugin-camera": {},
"cordova-plugin-filepath": {},
"cordova-admob-plus": {
"APP_ID_ANDROID": "ca-app-pub-xxxxxxxxxxxxx~xxxxxxxxxxxxx",
"PLAY_SERVICES_VERSION": "18.2.0"
}
},
"platforms": [
"android"
]
}
}
Does anyone see what is going wrong?
The problem is that the ionic plugin wrapper is broken and it just won't work. And it seems that it has been like that for a while, so it is not likely that it will be fixed anytime soon.
So, in order to make it work, uninstall everything admob-related:
ionic cordova plugin remove cordova-admob-plus
npm uninstall #ionic-native/admob-plus
Also remove from your code all the imports, instances and calls to the plugin. Then install just the cordova plugin:
cordova plugin add cordova-admob-plus --variable APP_ID_ANDROID=ca-app-pub-xxx~xxx --variable APP_ID_IOS=ca-app-pub-xxx~xxx
In the page that you are using admob on, add this before the #Component declaration:
declare var admob;
This variable will give you access to the plugin. Then you can load the banner like this:
admob.setDevMode(true);
admob.banner.show({
id: {
ios: 'ca-app-pub-xxx~xxx',
},
});
You can read more about this issue here
This is a solution that worked for me since the plugin has changed in 2022. I have the admob-plus-cordova plugin installed like this:
$ ionic cordova plugin add admob-plus-cordova --save --variable APP_ID_ANDROID=ca-app-pub-xxxx~yyyy --variable APP_ID_IOS=ca-app-pub-xxxx~yyyy
But when I used the #ionic-native/admob-plus with this, I also received the above error. I didn't want to use the Cordova plugin directly. So to resolve this, I did this:
npm uninstall #ionic-native/admob-plus
npm install #admob-plus/ionic
And then changed all reference to admob-plus From this:
import { AdMob } from '#ionic-native/admob-plus/ngx';
To This:
import { AdMob } from '#admob-plus/ionic/ngx';
That's it. Also make sure you review the code that shows the ad.
With reference to the documentation of admob plus you should use the package #admob-plus/ionic instead of #ionic-native/admob-plus.
This plugin is maintained by the same people as the cordova-package.
This should be better than directly working with cordova.

Cannot find module 'UNMET/package.json'

I'm trying to install a cordova plugin in my ionic app. But Every time and every plugin I try to install throws an error:
Cannot find module 'UNMET/package.json'
I already have to delete the paths: node_modules, plugins, platforms, www a lot of times.
I run:
npm install
ionic cordova plugin add cordova-plugin-local-notification
ionic cordova platform add android
and I tryied to change the order of this, but the problem don't be solved.
I'm running in a Ubuntu 18, ionic version is 4.8.0, cordova version is 9.0.0, cordova-lib 9.0.1, node version 8.10.0, npm 3.5.2.
I just run this line in terminal:
ionic cordova plugin add cordova-plugin-local-notification
my package json:
{
"name": "project-name",
"version": "0.0.1",
"author": "Ionic Framework",
"homepage": "http://ionicframework.com/",
"private": true,
"scripts": {
"android": "ionic cordova run android",
"start": "ionic-app-scripts serve",
"clean": "ionic-app-scripts clean",
"build": "ionic-app-scripts build",
"lint": "ionic-app-scripts lint",
"buildAndroid": "ionic cordova build android --aot --minifyjs --minifycss"
},
"dependencies": {
"#angular/animations": "5.2.11",
"#angular/common": "5.2.11",
"#angular/compiler": "5.2.11",
"#angular/compiler-cli": "5.2.11",
"#angular/core": "5.2.11",
"#angular/fire": "^5.1.1",
"#angular/forms": "5.2.11",
"#angular/http": "5.2.11",
"#angular/platform-browser": "5.2.11",
"#angular/platform-browser-dynamic": "5.2.11",
"#ionic-native/background-geolocation": "^4.20.0",
"#ionic-native/base64": "^4.20.0",
"#ionic-native/camera": "^4.20.0",
"#ionic-native/core": "~4.18.0",
"#ionic-native/crop": "^4.20.0",
"#ionic-native/facebook": "^4.20.0",
"#ionic-native/geolocation": "^4.20.0",
"#ionic-native/google-plus": "^4.20.0",
"#ionic-native/local-notifications": "^4.20.0",
"#ionic-native/location-accuracy": "^4.20.0",
"#ionic-native/social-sharing": "^4.20.0",
"#ionic-native/splash-screen": "~4.18.0",
"#ionic-native/sqlite": "^4.20.0",
"#ionic-native/status-bar": "~4.18.0",
"#ionic/storage": "2.2.0",
"#mauron85/cordova-plugin-background-geolocation": "3.0.3",
"brmasker-ionic-3": "^1.6.3",
"com-badrit-base64": "^0.2.0",
"cordova-plugin-badge": "^0.8.8",
"cordova-plugin-camera": "^4.0.3",
"cordova-plugin-crop": "^0.4.0",
"cordova-plugin-device": "^2.0.2",
"cordova-plugin-geolocation": "4.0.2",
"cordova-plugin-googleplus": "7.0.2",
"cordova-plugin-ionic-keyboard": "^2.1.3",
"cordova-plugin-ionic-webview": "^3.1.2",
"cordova-plugin-local-notification": "0.9.0-beta.2",
"cordova-plugin-request-location-accuracy": "2.3.0",
"cordova-plugin-splashscreen": "^5.0.2",
"cordova-plugin-statusbar": "^2.4.2",
"cordova-plugin-whitelist": "^1.3.3",
"cordova-plugin-x-socialsharing": "5.4.7",
"cordova-sqlite-storage": "^3.2.0",
"es6-promise-plugin": "4.2.2",
"firebase": "^5.8.4",
"ionic-angular": "3.9.3",
"ionicons": "3.0.0",
"ngx-multilingual": "0.0.3",
"rxjs": "5.5.11",
"sw-toolbox": "3.6.0",
"zone.js": "0.8.29"
},
"devDependencies": {
"#ionic/app-scripts": "3.2.1",
"#ionic/lab": "1.0.20",
"typescript": "~2.6.2"
},
"description": "An Ionic project",
"cordova": {
"plugins": {
"cordova-plugin-whitelist": {},
"cordova-plugin-statusbar": {},
"cordova-plugin-device": {},
"cordova-plugin-splashscreen": {},
"cordova-plugin-ionic-webview": {
"ANDROID_SUPPORT_ANNOTATIONS_VERSION": "27.+"
},
"cordova-plugin-ionic-keyboard": {},
"cordova-sqlite-storage": {},
"com-badrit-base64": {},
"cordova-plugin-camera": {
"ANDROID_SUPPORT_V4_VERSION": "27.+"
},
"cordova-plugin-crop": {},
"cordova-plugin-mauron85-background-geolocation": {
"GOOGLE_PLAY_SERVICES_VERSION": "11+",
"ANDROID_SUPPORT_LIBRARY_VERSION": "26+",
"ICON": "#mipmap/icon",
"SMALL_ICON": "#mipmap/icon",
"ACCOUNT_NAME": "#string/app_name",
"ACCOUNT_LABEL": "#string/app_name",
"ACCOUNT_TYPE": "$PACKAGE_NAME.account",
"CONTENT_AUTHORITY": "$PACKAGE_NAME"
},
"cordova-plugin-googleplus": {
"PLAY_SERVICES_VERSION": "11.8.0"
},
"cordova-plugin-geolocation": {
"GEOLOCATION_USAGE_DESCRIPTION": "Para pegar as melhores promoções"
},
"cordova-plugin-request-location-accuracy": {
"PLAY_SERVICES_LOCATION_VERSION": "16.+"
},
"cordova-plugin-x-socialsharing": {
"ANDROID_SUPPORT_V4_VERSION": "24.1.1+"
},
"cordova-plugin-local-notification": {}
},
"platforms": [
"android"
]
}
}
But every plugin throw this error.
I just need to install plugins in my app again.
Just update npm and you'll be able to build again :)

Ionic error while running in node modules

I get couple of errors in node modules while trying to run app using ionic and cordova build . I am getting error while running ionic cordova run androidcommand on command line. I also tried updating ionic and angular to latest build still showing me same error. Can you please help solving this issue. Following is my package.json file. Please have a look.
[01:39:24] typescript: F:/Ionic apps/myApp/node_modules/#ionic/app-scripts/dist
/util/interfaces.d.ts, line: 1
Cannot find type definition file for 'node'.
L1: import { CompilerHost, CompilerOptions, Program } from 'typescript';
L2: import { FileCache } from './file-cache';
[01:39:24] typescript: F:/Ionic apps/myApp/node_modules/#ionic/app-scripts/dist
/util/interfaces.d.ts, line: 131
Cannot find name 'Buffer'.
L130: writeFile(filePath: string, fileContent: Buffer, callback: Function)
: void;
L131: mkdirp(filePath: string, callback: Function): void;
L132: mkdir(filePath: string, callback: Function): void;
Error: Failed to transpile program
at BuildError.Error (native)
at new BuildError (F:\Ionic apps\myApp\node_modules\#ionic\app-scripts\dist\
util\errors.js:16:28)
at F:\Ionic apps\myApp\node_modules\#ionic\app-scripts\dist\transpile.js:159
:20
at transpileWorker (F:\Ionic apps\myApp\node_modules\#ionic\app-scripts\dist
\transpile.js:107:12)
at Object.transpile (F:\Ionic apps\myApp\node_modules\#ionic\app-scripts\dis
t\transpile.js:64:12)
at F:\Ionic apps\myApp\node_modules\#ionic\app-scripts\dist\build.js:109:82
[01:39:25] copy finished in 14.86 s
F:\Ionic apps\myApp>
Following is my package.json`
"name": "cricket",
"version": "0.0.1",
"author": "Ionic Framework",
"homepage": "http://ionicframework.com/",
"private": true,
"scripts": {
"clean": "ionic-app-scripts clean",
"build": "ionic-app-scripts build",
"lint": "ionic-app-scripts lint",
"ionic:build": "ionic-app-scripts build",
"ionic:serve": "ionic-app-scripts serve"
},
"dependencies": {
"#angular/animations": "5.2.9",
"#angular/common": "5.2.9",
"#angular/compiler": "5.2.9",
"#angular/compiler-cli": "5.2.9",
"#angular/core": "5.2.9",
"#angular/forms": "5.2.9",
"#angular/http": "5.2.9",
"#angular/platform-browser": "5.2.9",
"#angular/platform-browser-dynamic": "5.2.9",
"#firebase/app": "^0.1.10",
"#ionic-native/core": "4.5.3",
"#ionic-native/splash-screen": "4.5.3",
"#ionic-native/status-bar": "4.5.3",
"#ionic/pro": "1.0.20",
"#ionic/storage": "^2.1.3",
"angularfire2": "^5.0.0-rc.6.0",
"cordova-android": "^6.3.0",
"cordova-plugin-device": "^2.0.1",
"cordova-plugin-firebase": "^0.1.25",
"cordova-plugin-ionic-keyboard": "^2.0.5",
"cordova-plugin-ionic-webview": "^1.2.0",
"cordova-plugin-splashscreen": "^5.0.2",
"cordova-plugin-whitelist": "^1.3.3",
"cordova-sqlite-storage": "^2.3.0",
"firebase": "^4.13.1",
"ionic-angular": "3.9.2",
"ionicons": "3.0.0",
"path": "^0.12.7",
"rxjs": "5.5.7",
"sw-toolbox": "3.6.0",
"upstox": "^1.2.3",
"zone.js": "0.8.20"
},
"devDependencies": {
"#ionic/app-scripts": "^3.1.7",
"typescript": "~2.6.2"
},
"description": "An Ionic project",
"cordova": {
"plugins": {
"cordova-plugin-firebase": {},
"cordova-sqlite-storage": {},
"cordova-plugin-whitelist": {},
"cordova-plugin-device": {},
"cordova-plugin-splashscreen": {},
"cordova-plugin-ionic-webview": {},
"cordova-plugin-ionic-keyboard": {}
}
}
}
`
I solved this issue by checking cordova-android and #ionic/app-scripts compatibility from Changelog Description
1. Install cordova-android version (6.4.0 or 6.3.0) and #ionic/app-scripts version(3.1.8)
2. Remove android platform and add it agian.

navController.push does not open next page in release-apk

---update 1---
It looks like a minimization issue for prod build.
I can reproduce the error by using ionic cordova build android --prod to create apk and adb install to push the apk to the android device.
The error message is:
main.js:1 ERROR Error: Uncaught (in promise): Error: No provider for t!
Error: No provider for t!
at Error (native)
at O (file:///android_asset/www/build/main.js:1:6087)
at T (file:///android_asset/www/build/main.js:1:6346)
at t._throwOrNull (file:///android_asset/www/build/main.js:3:5428)
at t._getByKeyDefault (file:///android_asset/www/build/main.js:3:5761)
at t._getByKey (file:///android_asset/www/build/main.js:3:5146)
at t.get (file:///android_asset/www/build/main.js:3:3554)
at e.get [as _Logger_81] (file:///android_asset/www/build/main.js:25:21486)
---main thread---
I have 3-line code behind a button. The code is attached at the end.
All 3-line functionality works as expected in ionic serve and ionic cordova run android in a real android device.
However, the 3rd line does not work if the code/apk is:
1. built by `ionic cordova build android --prod --release`,
2. published to google play store,
3. installed to the same android device.
It means that DubPage is not opened by clicking the button.
What I troubleshooted:
1. this.logger.log() does send data to logentries, i.e. `goToDub`
function is called succesfully.
2. this.player.pause() does stop the html5 video player
3. I have no idea how to debug `this.navCtrl.push()`.
4. The only possible cause I can come up with is the lazy loading of `DubPage`, even though I dont quite believe it being the reason.
Any hint?
goToDub() {
this.logger.log(JSON.stringify(this.video)); //send log to 3rd party cloud log service: logentries
this.player.pause(); // stop html5 video player video.js in the page
this.navCtrl.push("DubPage", { video: this.video }); // go to DubPage does NOT work in play store released apk version;
}
In addtion, my package.json
{
"name": "dubwork",
"version": "0.0.1",
"author": "Ionic Framework",
"homepage": "http://ionicframework.com/",
"private": true,
"scripts": {
"clean": "ionic-app-scripts clean",
"build": "ionic-app-scripts build",
"lint": "ionic-app-scripts lint",
"ionic:build": "ionic-app-scripts build",
"ionic:serve": "ionic-app-scripts serve"
},
"dependencies": {
"#angular/common": "4.1.2",
"#angular/compiler": "4.1.2",
"#angular/compiler-cli": "4.1.2",
"#angular/core": "4.1.2",
"#angular/forms": "4.1.2",
"#angular/http": "4.1.2",
"#angular/platform-browser": "4.1.2",
"#angular/platform-browser-dynamic": "4.1.2",
"#ionic-native/camera": "3.10.2",
"#ionic-native/core": "3.10.2",
"#ionic-native/facebook": "^3.10.3",
"#ionic-native/file": "^3.10.3",
"#ionic-native/keyboard": "^3.10.3",
"#ionic-native/media": "^3.10.3",
"#ionic-native/splash-screen": "3.10.2",
"#ionic-native/status-bar": "3.10.2",
"#ionic-native/transfer": "^3.10.3",
"#ionic/storage": "2.0.1",
"angular2-logger": "^0.6.0",
"angularfire2": "^4.0.0-rc.1",
"cordova-android": "^6.2.3",
"cordova-plugin-compat": "^1.1.0",
"cordova-plugin-console": "^1.0.7",
"cordova-plugin-crosswalk-webview": "^2.3.0",
"cordova-plugin-device": "^1.1.6",
"cordova-plugin-facebook4": "^1.9.1",
"cordova-plugin-file": "^4.3.3",
"cordova-plugin-file-transfer": "^1.6.3",
"cordova-plugin-media": "^3.0.1",
"cordova-plugin-splashscreen": "^4.0.3",
"cordova-plugin-statusbar": "^2.2.3",
"cordova-plugin-whitelist": "^1.3.2",
"cordova-plugin-wkwebview-engine": "git+https://github.com/driftyco/cordova-plugin-wkwebview-engine.git",
"firebase": "^3.9.0",
"ionic-angular": "3.3.0",
"ionic-plugin-keyboard": "^2.2.1",
"ionicons": "3.0.0",
"rxjs": "5.1.1",
"sw-toolbox": "3.6.0",
"zone.js": "0.8.11"
},
"devDependencies": {
"#ionic/app-scripts": "1.3.7",
"#ionic/cli-plugin-cordova": "1.4.0",
"#ionic/cli-plugin-ionic-angular": "1.3.1",
"typescript": "2.3.3"
},
"description": "An Ionic project",
"cordova": {
"plugins": {
"cordova-plugin-facebook4": {
"APP_ID": "229997797493525",
"APP_NAME": "dubLearn-mobile"
},
"cordova-plugin-console": {},
"cordova-plugin-device": {},
"cordova-plugin-splashscreen": {},
"cordova-plugin-statusbar": {},
"cordova-plugin-whitelist": {},
"ionic-plugin-keyboard": {},
"cordova-plugin-crosswalk-webview": {
"XWALK_VERSION": "23+",
"XWALK_LITEVERSION": "xwalk_core_library_canary:17+",
"XWALK_COMMANDLINE": "--disable-pull-to-refresh-effect",
"XWALK_MODE": "embedded",
"XWALK_MULTIPLEAPK": "true"
},
"cordova-plugin-wkwebview-engine": {},
"cordova-plugin-media": {},
"cordova-plugin-file-transfer": {}
},
"platforms": [
"android"
]
}
}
It turns out that the error was caused by using angular2-logger package alone. logentries is irrelevant.
Steps to reproduce the issue:
ionic start logger-bug blank
npm install --save angular2-logger
add angular2-logger package in app.module.ts provider
add angular2-logger package in home.ts and log a debug message
using ionic cordova run android, the app opens in android device without error
using ionic cordova run android --prod, the app shows promise t error