1

I have an ionic vue app that I want to test as an android app.

I use following commands to create the app:

ionic cap add android
ionic build
ionic cap copy
ionic cap open android

Then I start the app on a virtual device in android studio. I use android API Level 30.

I get an ERR_CLEARTEXT_NOT_PERMITTED error when calling my django api (which I started locally, that's why there is no https).

I already tried adding this to my capacitor.config

server: {
  cleartext: true
}

This results in another error message: net::ERR_CONNECTION_REFUSED.

I already tried various other things like suggested here: Ionic 5/Capacitor ERR_CLEARTEXT_NOT_PERMITTED in Android, but none helped so far.

When I use an Android version before API level 28 I get the net::ERR_CONNECTION_REFUSED right away

lando
  • 335
  • 1
  • 16
  • when I change my axios baseURL from localhost to 10.0.2.2 it's working. But then of course the iOS and web app aren't working. Any idea on how to do that? – lando Aug 28 '21 at 14:41

1 Answers1

1

I solved it by just adding a condition in my axios config:

const host = isPlatform('android') ? '10.0.2.2' : 'localhost'
lando
  • 335
  • 1
  • 16