"ionic cordova run android --device" is not working on Mac

  1. connect my android phone to Mac.

  2. $ionic cordova run android --device

  3. it comes out error like below…

  4. do I need to make “tsconfig.json” file? but I don’t know what it contains

  5. I want to run test code on my real android phone…

  6. my ionic info is…
    cli packages: (/usr/local/lib/node_modules)

    @ionic/cli-utils : 1.19.2
    ionic (Ionic CLI) : 3.20.0

global packages:

cordova (Cordova CLI) : 7.1.0 

local packages:

@ionic/app-scripts : 3.2.4
Cordova Platforms  : android 6.3.0 ios 4.5.5
Ionic Framework    : ionic-angular 3.9.9


Node  : v6.11.3
npm   : 3.10.10 
OS    : macOS
Xcode : Xcode 12.4 Build version 12D4e 

Environment Variables:

ANDROID_HOME : not set


backend : pro

You can try this, create the file tsconfig.json in root project

  "compilerOptions": {
    "allowSyntheticDefaultImports": true,
    "declaration": false,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "lib": ["dom", "es2015"],
    "module": "es2015",
    "moduleResolution": "node",
    "sourceMap": true,
    "target": "es5"
  "include": ["src/**/*.ts"],
  "exclude": ["node_modules/**/*.ts"],
  "compileOnSave": false,
  "atom": {
    "rewriteTsconfig": false

Thank you for your quick reply :slight_smile:
That error passed but new error appeared…

what does wrong?

You must create file network_security_config.xml in the, resources/android/xml/network_security_config.xml

<?xml version="1.0" encoding="utf-8"?>


    <domain-config cleartextTrafficPermitted="true">

        <domain includeSubdomains="true">localhost</domain>



Check in your config.xml if already exist this config in the platform android

<edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application" xmlns:android="http://schemas.android.com/apk/res/android">
            <application android:networkSecurityConfig="@xml/network_security_config" />

it solved by edit config.xml file like this:

target=“app/src/main/res/xml/network_security_config.xml” → target=“res/xml/network_security_config.xml”

1 Like

Thanks for your reply! :slight_smile: