I was having this exact problem while using Ionic with Capacitor to run the livereload version of the app (debug). The issue arose when I upgraded Android Studio from Giraffe to Ladybug.
I tried most of the things in the other answers but couldn't make it work.
Then I just compiled the app for a standard build (apk) instead of the livereload project and that way actually worked.