Can't add Android to Ionic 4 Capacitor app as www is empty

I am just starting to play with Ionic 4 and Capacitor.

Following the doco, I attempted to add Android to the blank Ionic 4 application I have just created, and got the following error…

$ npx cap add android
npx: installed 1 in 2.363s
Path must be a string. Received undefined
C:\dev\ionic\sqlite-test\node_modules\@capacitor\cli\bin\capacitor
[error] The web directory (C:\dev\ionic\sqlite-test\www) must contain a "index.html".
    It will be the entry point for the web portion of the Capacitor app.

Also, even though I have been running the app (using Ionic serve), I notice my www folder is empty! So not sure where the app is building to?

Any ideas here greatly appreciated.

Interesting… Ionic serve does not do a build into www. I had to run ionic build. I could then run the npx cap add android. Now I know.

3 Likes

if this happened, edit your capacitor.config.json, {“webDir”: “build”}

Yes, this is working.

I think this should be added to the documentation. I just created a brand new ionic 5 capacitor angular app and had to do this. It’s not mentioned or stepped through enough sometimes.

3 Likes

This is really terrible. I think that Ionic is getting WORSE and WORSE. New developers cannot learn anything because of hundreds of errors in blank empty template. Ionic still chaning something and it started to be useless :frowning:

4 Likes