Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
marciusbezerra opened this issue Dec 30, 2017 · 37 comments
Closed

Comments

@marciusbezerra
Copy link

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
@DoubleMalt
Copy link

Same here :(

@SteveKennedy
Copy link

I'm pretty sure this is related to ionic-team/ionic-app-scripts#1354

@pistou
Copy link

pistou commented Mar 12, 2018

Still a thing 👎

@itslenny
Copy link

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

@rich186
Copy link

rich186 commented Mar 21, 2018

I had the same problem and ended up downgrading from [email protected] to [email protected]. Fixed the issue (temporarily).

@gaurav-chandra
Copy link

Any update on this? This is very annoying.

@distante
Copy link

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

@SteveKennedy
Copy link

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

@Maevus
Copy link

Maevus commented Apr 11, 2018

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');

@msholly
Copy link

msholly commented Apr 12, 2018

@SteveKennedy This is probably the best solution, since its not always a good idea to edit anything in the node_modules folder. But I have a change to your gist.

Line 37 should be

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

While your current code makes sense, the hook did nothing unless I changed it to above. But once changed, everything is working well in Corvoda 7.1.0. Thanks for your contribution!

@distante
Copy link

While the gist and/or the suggested edit works it makes the normal ionic serve think it is on a device with live reload too.

@msholly
Copy link

msholly commented Apr 13, 2018

Interesting! Ultimately its a bug that will be addressed in the future by Ionic or Cordova teams, but this fix at least let me continue working on the emulator.

@giladrom
Copy link

You would think that this bug would be at the top of their queue. Strange.

@fernandocode
Copy link

This is a problem that should be treated as a priority because it is a BUG. Today I lost 3~4 hours until I get here, not to mention that when leaving the project of the repositiorio we will have to remember to edit the file.

@distante
Copy link

distante commented Apr 23, 2018

Here says that the latest release fix this problem.

@nlzet
Copy link

nlzet commented Apr 24, 2018

Yes, I believe this merged PR should solve this issue: ionic-team/ionic-app-scripts#1407

@gubbigubbi
Copy link

I imagine the team is pretty busy with the v4. I can confirm that with ionic v3.2 this is still an issue - @msholly 's instructions fix the problem. gang gang.

@wilsolutions
Copy link

wilsolutions commented Jul 10, 2018

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

@gleysonlf
Copy link

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.

@maris144
Copy link

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

@giuseeFG
Copy link

giuseeFG commented Sep 4, 2018

same here

@zypro
Copy link

zypro commented Sep 5, 2018

Is there a workaround for debugging or testing faster?

@rodrigosanchezg8
Copy link

Same here, this is driving me nuts

@vipin-developer
Copy link

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

@intersides
Copy link

intersides commented Oct 19, 2018

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

@tgirgin23
Copy link

I started having the same issue when upgrading from ionic 4.0.0-beta.11 to 4.0.0-beta.12. Decided to downgrade for the time being until the next beta version.

Just had some time to upgrade to 4.0.0-beta.13, and this is still an issue.

@aniciom
Copy link

aniciom commented Oct 28, 2018

try ./node_modules/.bin/ionic-app-scripts serve --sourceMap source-map --iscordovaserve --wwwDir platforms/browser/www/ --buildDir platforms/browser/www/build

This is for v3

@RafaelKr
Copy link

@tgirgin23 I also tried to downgrade to @ionic/4.0.0-beta.11 but for me it's not working.
I also removed node_modules, reinstalled and removed and added the platform android.

@tgirgin23
Copy link

@RafaelKr Here is my ionic info (nodejs version is actually 10+, just had to switch for another project in the meantime). Hopefully this can help you.

✔ Gathering environment info - done!
Ionic:

   ionic (Ionic CLI)             : 4.2.1 (/usr/local/lib/node_modules/ionic)
   Ionic Framework               : @ionic/angular 4.0.0-beta.11
   @angular-devkit/build-angular : 0.7.5
   @angular-devkit/schematics    : 0.7.5
   @angular/cli                  : 6.1.5
   @ionic/angular-toolkit        : not installed

Cordova:

   cordova (Cordova CLI) : 8.1.2 ([email protected])
   Cordova Platforms     : ios 4.5.5
   Cordova Plugins       : cordova-plugin-ionic-keyboard 2.1.2, cordova-plugin-ionic-webview 2.1.3, (and 7 other plugins)

System:

   NodeJS : v9.11.1 (/usr/local/bin/node)
   npm    : 5.6.0
   OS     : macOS High Sierra
   Xcode  : Xcode 9.4.1 Build version 9F2000```

@RafaelKr
Copy link

@tgirgin23 thanks for sharing!

I tried to mirror your environment as close as possible, but after uninstalling @ionic/[email protected] it says Error: Could not find module "@ionic/angular-toolkit" from /path/to/my/project

[ERROR] Error loading @ionic/angular-toolkit package.json: Error: Cannot find module '@ionic/angular-toolkit/package'
✔ Gathering environment info - done!

Ionic:

   ionic (Ionic CLI)             : 4.2.1 (/home/rafael/.nvm/versions/node/v9.11.1/lib/node_modules/ionic)
   Ionic Framework               : @ionic/angular 4.0.0-beta.11
   @angular-devkit/build-angular : 0.7.5
   @angular-devkit/schematics    : 0.7.5
   @angular/cli                  : 6.1.5
   @ionic/angular-toolkit        : not installed

Cordova:

   cordova (Cordova CLI) : 8.1.2 ([email protected])
   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            : v9.11.1 (/home/rafael/.nvm/versions/node/v9.11.1/bin/node)
   npm               : 5.6.0
   OS                : Linux 4.10

@tgirgin23
Copy link

@RafaelKr Yes, I got the same error. Everything is still working fine though... weird.

@zzdumeng
Copy link

zzdumeng commented Nov 2, 2018

I am using Ionic 4.3.0, and still got this issue.
Hope this will have high priority in ionic team.

Ionic:

ionic (Ionic CLI) : 4.3.0 (/Users/user/.config/yarn/global/node_modules/ionic)
Ionic Framework : @ionic/angular 4.0.0-beta.13
@angular-devkit/build-angular : 0.8.6
@angular-devkit/schematics : 0.8.6
@angular/cli : 6.2.6
@ionic/angular-toolkit : 1.0.0

Cordova:

cordova (Cordova CLI) : 8.1.2 ([email protected])
Cordova Platforms : ios 4.5.5
Cordova Plugins : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 2.2.0, (and 6 other plugins)

System:

ios-deploy : 1.9.4
NodeJS : v10.9.0 (/Users/user/.nvm/versions/node/v10.9.0/bin/node)
npm : 6.2.0
OS : macOS
Xcode : Xcode 10.1 Build version 10B61

@RafaelKr
Copy link

RafaelKr commented Nov 3, 2018

It works again!

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

npm i -D @ionic/[email protected]

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 ([email protected])
   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

@tgirgin23
Copy link

tgirgin23 commented Nov 4, 2018

Installing the new ionic angular-toolkit has sadly not fixed the issue for me on 4.0.0beta15.

@RafaelKr Could you please post an ionic info so that I could compare?

This seems to be working using the new ionic angular toolkit, however i had to start a new ionic project and copy all my code in there.

@RafaelKr
Copy link

RafaelKr commented Nov 5, 2018

@tgirgin23 nice to hear it's working! I have added my ionic info anyway.

@collindutter
Copy link

Not sure why but transferring all my files to a fresh project worked for me too!

@ionitron-bot
Copy link

ionitron-bot bot commented Dec 29, 2018

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Dec 29, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests