ionic-framework: New Ionic + new Cordova no longer work for debugging (with livereload)

Ionic version: (check one with “x”) (For Ionic 1.x issues, please use https://github.com/ionic-team/ionic-v1) [ ] 2.x [x] 3.x [ ] 4.x

I’m submitting a … (check one with “x”) [x] bug report [ ] feature request

Current behavior:

New Ionic + new Cordova no longer work for debugging (with livereload)

Expected behavior: run normally with cordova in livereload mode

Steps to reproduce:

On a new computer, I installed:

  • Java
  • Ant
  • Andrioid Studio
  • NodeJs
  • Ionic and
  • Cordova

And after everything configured just like the Ionic documents, I created a new basic app:

ionic start myApp tabs

The application even runs normally, but when I go to debug:

ionic cordova run android -lc

I get the following message:

console.warn: Native: tried calling StatusBar.styleDefault, but Cordova is not available. Make sure to include cordova.js or run in a device/simulator
console.warn: Native: tried calling SplashScreen.hide, but Cordova is not available. Make sure to include cordova.js or run in a device/simulator

Related code:

Normal code, generated by Ionic’s own standard template tabs

Other information:

cli packages: (C:\Users\marci\AppData\Roaming\npm\node_modules)

    @ionic/cli-utils  : 1.19.0
    ionic (Ionic CLI) : 3.19.0

global packages:

    cordova (Cordova CLI) : 8.0.0

local packages:

    @ionic/app-scripts : 3.1.6
    Cordova Platforms  : android 7.0.0
    Ionic Framework    : ionic-angular 3.9.2

System:

    Android SDK Tools : 26.1.1
    Node              : v8.9.3
    npm               : 5.5.1
    OS                : Windows 10

Environment Variables:

    ANDROID_HOME : d:\AndroidSdk

Misc:

    backend : pro

Cordova requirements:

Android Studio project detected

Requirements check results for android:
Java JDK: installed 1.8.0
Android SDK: installed true
Android target: installed android-26,android-25,android-24,android-23,Google Inc.:Google APIs:23
Gradle: installed C:\Program Files\Android\Android Studio\gradle\gradle-3.2\bin\gradle

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 15
  • Comments: 37

Most upvoted comments

As a workaround you can edit

node_modules/@ionic/app-scripts/dist/dev-server/serve-config.js

replace

exports.ANDROID_PLATFORM_PATH = path.join('platforms', 'android', 'assets', 'www');

with

exports.ANDROID_PLATFORM_PATH = path.join('platforms', 'android', 'app', 'src', 'main', 'assets', 'www');

From this StackOverflow question

Any update on this? This is very annoying.

same here

Same here

cli packages: (C:\Users\myUser\AppData\Roaming\npm\node_modules)

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

global packages:

    cordova (Cordova CLI) : 8.0.0

local packages:

    @ionic/app-scripts : 3.1.8
    Cordova Platforms  : android 7.1.0
    Ionic Framework    : ionic-angular 3.9.2

System:

    Android SDK Tools : 26.1.1
    Node              : v8.11.0
    npm               : 5.6.0
    OS                : Windows 10

Environment Variables:

    ANDROID_HOME : C:\Users\myUser\AppData\Local\Android\sdk

Misc:

    backend : legacy

Is there a workaround for debugging or testing faster?

I’m testing ionic 4 and I have the same problem =( when using the http-native.

I made a Cordova hook that you can add to your config.xml. It will edit the file that @itslenny mentions above. If you don’t know what Cordova Hooks are, you can find more information at https://cordova.apache.org/docs/en/latest/guide/appdev/hooks/. I recommend adding it like this

<hook src="scripts/fixcordova7issue.js" type="before_prepare" />

The code for the webhook is in this gist: https://gist.github.com/SteveKennedy/a9964b291afa51f820b5d73b687eeb34

It works again!

They just fixed it with an angular-toolkit update. Install it with

npm i -D @ionic/angular-toolkit@1.1.0

Source: https://github.com/ionic-team/angular-toolkit/blob/master/CHANGELOG.md

Edit:

✔ Gathering environment info - done!

Ionic:

   ionic (Ionic CLI)             : 4.2.1 (/home/rafael/.nvm/versions/node/v10.7.0/lib/node_modules/ionic)
   Ionic Framework               : @ionic/angular 4.0.0-beta.15
   @angular-devkit/build-angular : 0.7.5
   @angular-devkit/schematics    : 0.7.5
   @angular/cli                  : 6.1.5
   @ionic/angular-toolkit        : 1.1.0

Cordova:

   cordova (Cordova CLI) : 8.1.2 (cordova-lib@8.1.1)
   Cordova Platforms     : android 7.1.1
   Cordova Plugins       : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 2.2.0, (and 10 other plugins)

System:

   Android SDK Tools : 26.1.1 (/home/rafael/android-sdk-linux)
   NodeJS            : v10.7.0 (/home/rafael/.nvm/versions/node/v10.7.0/bin/node)
   npm               : 6.4.1
   OS                : Linux 4.10

I am not able to find this file what should i do

FIX: You need go to node_modules/@ionic/app-scripts/dist/dev-server/serve-config.js

node_modules/@ionic does only contains 3 folders, angular, angular-toolkit and core . There is no trace of app-scripts

I have a same problem

My info

Ionic:

ionic (Ionic CLI) : 4.1.1

System:

NodeJS : v8.11.1 npm : 6.4.0 OS : Windows 10

I’m testing ionic 4 and I have the same problem. Now in the file “server-config.js” it looks like this:

exports.ANDROID_PLATFORM_PATHS = [ path.join(‘platforms’, ‘android’, ‘assets’, ‘www’), path.join(‘platforms’, ‘android’, ‘app’, ‘src’, ‘main’, ‘assets’, ‘www’) ];

The warn persists.

Still an issue with Ionic 3.20.0.

The fix described here on stackoverflow worked for me.

FIX: You need go to node_modules/@ionic/app-scripts/dist/dev-server/serve-config.js and replace exports.ANDROID_PLATFORM_PATH = path.join(‘platforms’, ‘android’, ‘assets’, ‘www’); to exports.ANDROID_PLATFORM_PATH = path.join(‘platforms’, ‘android’, ‘app’, ‘src’, ‘main’, ‘assets’, ‘www’);