Unable to run Ionic cordova run android


I’m using ionic 6.20.6 and angular 15.0.4 with latest gradle and android studio, also I have cordova 11 installed but when running ionic cordova run android -l I’m getting the following error:

 ng.cmd run app:ionic-cordova-serve --host=localhost --port=8100 --platform=android
[ng] This version of CLI is only compatible with Angular versions ^14.0.0,
[ng] but Angular version 15.0.4 was found instead.
[ng] Please visit the link below to find instructions on how to update Angular.
[ng] https://update.angular.io/

[ERROR] ng has unexpectedly closed (exit code 3).

        The Ionic CLI will exit. Please check any output above for error details.

Hi, It seems that the ionic cordova run android command only work with angular version 14 at the moment.

I found a similar issue (bug: angular toolkit should work in angular 14 · Issue #474 · ionic-team/angular-toolkit · GitHub) that the command only works for angular 13 but failed with angular 14.

The issue was eventually solved by the ionic team released a newer major version of @ionic/cordova-builders, which add angular 14 support and drop angular 13 support.

So we may need to wait for ionic team release the newer version of @ionic/cordova-builders package for adding angular 15 support.

I come up some options you can do as a quick workaround:

  1. downgrade angular version to 14
  2. or using Capacitor instead of cordova, because Capacitor works well with angular 15. (side note: Differences between Capacitor and Cordova)

From my personal experience, I prefer option 2. using Capacitor because:

  1. A Capacitor project can utilize both Capacitor plugins and cordova plugins (a cordova project can only utilize cordova plugins), which means you can find a native plugin that suit your need more easily.
  2. It’s easier to modified native project code if need.

But depending on what you are trying to achieve, either options is OK :smile:

Thanks a lot for your help.

1 Like

Quick question though how do I force @ionic/cli to force the installation of angular v14 when create an app from scratch.

@jonz94 please help me on this one

I think @ionic/cli can only create angular v15 project for now.

But you can simply create a v15 project, and then change the angular version from v15 to v14 inside package.json settings:

  "dependencies": {
-    "@angular/common": "^15.0.0",
-    "@angular/core": "^15.0.0",
-    "@angular/forms": "^15.0.0",
-    "@angular/platform-browser": "^15.0.0",
-    "@angular/platform-browser-dynamic": "^15.0.0",
-    "@angular/router": "^15.0.0",
+    "@angular/common": "^14.0.0",
+    "@angular/core": "^14.0.0",
+    "@angular/forms": "^14.0.0",
+    "@angular/platform-browser": "^14.0.0",
+    "@angular/platform-browser-dynamic": "^14.0.0",
+    "@angular/router": "^14.0.0",
    "@ionic/angular": "^6.1.9"
  "devDependencies": {
-    "@angular-devkit/build-angular": "^15.0.0",
+    "@angular-devkit/build-angular": "^14.0.0",
    "@angular-eslint/builder": "^14.0.0",
    "@angular-eslint/eslint-plugin": "^14.0.0",
    "@angular-eslint/eslint-plugin-template": "^14.0.0",
    "@angular-eslint/template-parser": "^14.0.0",
-    "@angular/cli": "^15.0.0",
-    "@angular/compiler": "^15.0.0",
-    "@angular/compiler-cli": "^15.0.0",
-    "@angular/language-service": "^15.0.0",
+    "@angular/cli": "^14.0.0",
+    "@angular/compiler": "^14.0.0",
+    "@angular/compiler-cli": "^14.0.0",
+    "@angular/language-service": "^14.0.0",
-    "@ionic/angular-toolkit": "^6.0.0",
+    "@ionic/angular-toolkit": "^7.0.0",

After that, run rm -fr node_modules/ package-lock.json command and then npm install command to regenerate node_modules/ and package-lock.json.

Well this change in versions for angular does help me build the application and launch it on Android devices but now on Android emulator I’m getting a new error.
I have attached the screenshot below:

Not sure why this happening.
here is content from AndroidManifest.xml

<?xml version='1.0' encoding='utf-8'?>
<manifest android:hardwareAccelerated="true" android:versionCode="1" android:versionName="0.0.1" package="io.ionic.starter" xmlns:android="http://schemas.android.com/apk/res/android">
    <supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <application android:hardwareAccelerated="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:networkSecurityConfig="@xml/network_security_config" android:supportsRtl="true" android:usesCleartextTraffic="true">
        <activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode" android:exported="true" android:label="@string/activity_name" android:launchMode="singleTop" android:name="MainActivity" android:theme="@style/Theme.AppCompat.NoActionBar" android:windowSoftInputMode="adjustResize">
            <intent-filter android:label="@string/launcher_name">
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />