Ready, how to build

Please describe the question in detail and share your code, configuration, and other relevant info.

I installed Ionic yesterday on Ubuntu 20.04, so I hope I am using Ionic 5.

Once we set up the HTML, CSS and Angular, what to do next to build the app ?

I tried

ionic build prod

npx cap add android

but when I try npx cap open android

it asks me to add the location of Android Studio’s studio.sh file in a particular format inside

capacitor.config.json

But doing so brings no change. The project won’t open in Android Studio even if I redo the npx cap open android command.

After giving up, I tried open the my-app folder in Android Studio through the GUI and it worked without any problem. It also gives some notifications like framework found, gradle
and so on. But when I click Run, nothing happens. There is no option to Build at all.

It would be nice to know how to get past these and make a successful build. I know this is very trivial for many of you. But I am really finding it hard to build an apk from the completed project. Thanks.

Look at the irony

I used the output of ionic capacitor build android inside Android Studio

Some help would be great.

Did you try to run File -> Sync Project With Gradle Files?

1 Like

No sir, this is where I am now, only 3 commands tried

ionic prod

ionic capacitor add android

ionic capacitor build android

I tried like a no. of videos and blogs that came through Google. Each had their own version. Things go well until I open the project folder in Android Studio. Once it said license not valid for Android 29. I managed to use the SDK Manager and add the necessary dependencies. But it gave something else afterwards.

It would be nice to have a resource where it says the commands in order so that beginners like me can simply imitate. Thanks.

In Android Studio, if you installed SDK 29, then you should use that menu open that I put above. With Android development, you need to periodically run the Gradle sync, it’s just part of life doing Android dev. We have a list of common troubleshooting tips for Android on the docs: https://capacitorjs.com/docs/android/troubleshooting

1 Like

Thanks a lot. If you don’t mind. Let us say I have my folders ready. Now I need www and android and then apk. I have so far only tried

ionic start
ionic serve

Will it be possible to know the commands to use. I guess there would be 3-4 of them. I will simply leave my old attempts and start afresh if I know which commands to use At one point Android Studio told me that there are 6 AndroidManifest.xml file and when tried to run the app, it says AndroidManifest.xml is missing.

Just sharing my experience so far. :slight_smile:

Tried to check Ionic version in Terminal

$ ionic -v
6.12.3

Update 1:

I managed to get a successful build this time. After finishing HTML code,

ionic build for www folder generation

ionic capacitor add android adds the android folder

Opened the android folder using Andriod Studio, it performed Gradle sync and I tried Run which gave a clean output in AVD. Then generated a Signed apk

All good other than the fact that the links added to ion-card are not clickable.

<ion-card href="https://youtu.be/zcrUCvBD16k">
  <ion-card-header>
    
    <ion-card-title>BBC/ion-card-title>
  </ion-card-header>

  <ion-card-content>
    abc 
  </ion-card-content>
</ion-card>