Ionic capacitor Android build no target

I am trying to get my Ionic5 + Capacitor app to build for Android. I followed the officil steps here

ionic capacitor add android
ionic capacitor copy android

and opened the project in Android Studio.
Here, I hit a blocker because there is no target app to build. If I create a new through “Add Configuration” I have no module to select that would be launched in the app. Hence I can not build the app. The steps I took seem incomplete.

Tried

ionic build
ionic capacitor run android

as well, still no build target

Anyone have an idea? I my project not configured properly? iOS builds fine btw.
enter image description here

Hmmm, that’s odd. Can you try running npx cap sync android after running ionic build?

No, still the same outcome. I also tried ionic capacitor sync android before.

I don’t think it matters, but I am running this within a Parallels VM because I do not want to break my production build environment on the host (yet).

Try doing File -> Sync project with gradle files

You can build directly from your terminal without opening android studio. Check ionic-capacitor commands

1 Like

Thanks for the link. I was able to generate the debug app, so that worked! But it failed to install “App not installed” . Got to look to find some logs to figure out why it fails installation.

Can you try to uninstall and reinstall again?

You mean the android folder? I’ve been doing that… rm -rf android ionic capacitor add android but it did not change anything.

Hey, I’ve the same issue, tried totally reinstall and manually configure, but finally figured out that I haven’t installed proper version of SDK (from ionic app init it requires 28 (android 9.0 Pie)). After I’ve installed it synced with gradle files correctly and runs project smoothly.

Hope this could help somebody :slightly_smiling_face:

1 Like

I got it to work a while ago but forgot what the exact solution was… I think in the end I am not using the Android Studio IDE to build it. I ended up using the CLI commands with gradle etc.