cant complete ionic capacitor add android command
Asked Answered
D

4

6

I am trying to add android as a supported platform to my project by running the command: ionic capacitor add android.

The command is executed and stops at a prompt which asks me "which npm client would you like to use ? (use arrow keys), with yarn being the only option.

The problem is I am stuck at this point and pressing the arrow keys do not register anything (the keys work fine) and I cant even select the only option I am given

So far I have tried: uninstalling yarn creating new project deleting the node_modules updating all modules

Nothing seems to work. On the plus side though when I attempted to do these steps on another machine it all worked well and I never got the prompt, which makes it unique to only my main workstation. I am still trying to figure out why I get the problem on this specific machine

Dissension answered 7/5, 2019 at 2:26 Comment(0)
N
18

It's a bug on the ionic CLI. It's been fixed, but not released yet. https://github.com/ionic-team/capacitor/issues/1453

As workaround you can remove the --capacitor option when creating the project, and then do the integration manually like this:

npm install @capacitor/core @capacitor/cli

npx cap init

And let Ionic know you did the integration by adding this to the ionic.config.json

"integrations": {
    "capacitor": {}
},
Nonconformist answered 7/5, 2019 at 10:36 Comment(1)
can you accept the answer as it solved your problem?Nonconformist
S
10

Issue: Unable to add Android platform

I got this issue while adding the android platform in the Ionic Capacitor app using the below command.

$ ionic capacitor add android

It seems a bug in Ionic CLI (as mentioned above). So, I thought to use Capacitor CLI instead.

Solution:

As a workaround, I did the following:

$ npm install @capacitor/android
$ npx capacitor add android

This successfully added the android folder to my project.

Sawfish answered 20/5, 2021 at 20:17 Comment(0)
L
1

Firstly, you need to build your app in order to create the correct files before open up on android studio.

you can just run:

$ ionic capacitor build android
$ ionic capacitor run android

Make sure your android-studio is at the correct path and you have downloaded the tons of avd, updates and so on.

Landmark answered 21/5, 2021 at 17:38 Comment(0)
F
0

Following the below steps are working for me

npx cap init

"integrations": { "capacitor": {} },

npm install @capacitor/android

ionic capacitor add android

Falcate answered 14/7, 2021 at 15:21 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.