Fail to debug ionic cordova

Hi, I am running ionic 5 with angular 9 and I am getting this error log when I try to debug the app on android. I am uding the following command line ionic cordova run android --device -l --debug.

Thank you for your help

[error] TypeError: context.getProjectMetadata is not a function

at Object.configureI18nBuild (C:\Users\Mario\Documents\ionic\capstone\client\node_modules\@angular-devkit\build-angular\src\utils\i18n-options.js:99:36)

at Object.generateI18nBrowserWebpackConfigFromContext (C:\Users\Mario\Documents\ionic\capstone\client\node_modules\@angular-devkit\build-angular\src\utils\webpack-browser-config.js:85:57)

at Object.buildBrowserWebpackConfigFromContext (C:\Users\Mario\Documents\ionic\capstone\client\node_modules\@angular-devkit\build-angular\src\browser\index.js:67:41)

at setup (C:\Users\Mario\Documents\ionic\capstone\client\node_modules\@angular-devkit\build-angular\src\dev-server\index.js:103:63)

package.json likely relevant.

What do you mean relevant ?

That you posting it will improve the chances of anybody being able to help you.

O ok,

{

“name”: “cstone”,

“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”: {

"@angular-devkit/architect-cli": "^0.901.4",

"@angular/animations": "^9.1.0",

"@angular/cdk": "^9.2.0",

"@angular/common": "~9.1.0",

"@angular/core": "^9.1.4",

"@angular/forms": "~9.1.0",

"@angular/material": "^9.2.0",

"@angular/platform-browser": "~9.1.0",

"@angular/platform-browser-dynamic": "~9.1.0",

"@angular/router": "^9.1.0",

"@auth0/angular-jwt": "^3.0.1",

"@capacitor/android": "^2.0.2",

"@capacitor/core": "2.0.2",

"@ionic-native/barcode-scanner": "^5.24.0",

"@ionic-native/core": "^5.24.0",

"@ionic-native/splash-screen": "^5.0.0",

"@ionic-native/status-bar": "^5.0.0",

"@ionic/angular": "^5.0.7",

"@ionic/storage": "^2.2.0",

"angular": "^1.7.9",

"angular-jwt": "github:auth0/angular-jwt",

"angularx-qrcode": "^2.1.1",

"body-parser": "^1.19.0",

"buffer": "^5.4.3",

"cordova-android": "8.1.0",

"core-js": "^2.5.4",

"dotenv": "^8.2.0",

"eslint": "^6.8.0",

"express": "^4.17.1",

"ionic": "^5.4.15",

"jsqr": "^1.3.1",

"multer": "^1.4.2",

"phonegap-plugin-barcodescanner": "^8.1.0",

"rxjs": "~6.5.4",

"tslib": "^1.11.1",

"zone.js": "~0.10.3"

},

“devDependencies”: {

"@angular-devkit/architect": "^0.901.4",

"@angular-devkit/build-angular": "^0.901.0",

"@angular-devkit/core": "~9.1.0",

"@angular-devkit/schematics": "~9.1.0",

"@angular/cli": "~9.1.0",

"@angular/compiler": "~9.1.0",

"@angular/compiler-cli": "~9.1.0",

"@angular/language-service": "~9.1.0",

"@capacitor/cli": "2.0.2",

"@ionic/angular-toolkit": "^2.2.0",

"@ionic/lab": "^3.1.2",

"@types/jasmine": "~3.3.8",

"@types/jasminewd2": "~2.0.3",

"@types/node": "^8.10.59",

"codelyzer": "^5.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.4.0",

"jasmine-spec-reporter": "~4.2.1",

"karma": "^5.0.4",

"karma-chrome-launcher": "~2.2.0",

"karma-coverage-istanbul-reporter": "~2.0.1",

"karma-jasmine": "~2.0.1",

"karma-jasmine-html-reporter": "^1.4.0",

"protractor": "^5.4.3",

"ts-node": "^8.8.1",

"tslint": "~5.15.0",

"typescript": "~3.8.3"

},

“description”: “An Ionic project”,

“main”: “karma.conf.js”,

“keywords”: ,

“license”: “ISC”,

“cordova”: {

"plugins": {

  "phonegap-plugin-barcodescanner": {},

  "cordova-plugin-whitelist": {},

  "cordova-plugin-statusbar": {},

  "cordova-plugin-device": {},

  "cordova-plugin-splashscreen": {},

  "cordova-plugin-ionic-webview": {

    "ANDROID_SUPPORT_ANNOTATIONS_VERSION": "28.+"

  },

  "cordova-plugin-ionic-keyboard": {}

},

"platforms": [

  "android"

]

}

}

These two definitely need to go away, and hint to me that this project has been upgraded in place all the way from v1. It might be best long-term to create a brand-new project and parachute your app code into it, instead of continuing to nurse this one along, but continuing…

These also stand out to me as extremely unusual in an Ionic project. Why on earth would you need a webserver in an Ionic app?

So, in summary, even if you don’t want to go with the recommended approach of using a new project, I would suggest spawning one and comparing its package.json with the one you currently have, trying to aggressively prune out everything that isn’t in the newly spawned project and aligning the versions to match it.

There is still a fairly significant possibility that your auxiliary configuration files (angular.json, tsconfig.json, &c) aren’t compatible with the toolchain you’re using, so I still think the best long-term solution is to make a new project.

Ok tnx for the recommendation.

I got it working btw without making a new project. Had to enable developer options on the mobile :upside_down_face:

Use this command ionic cordova run android
by default is used debug mode and run for build install to the device

1 Like