Unable to open asset URL - ionic, Android

Viewed 35

I'm building an ionic application and I faced with an issue that affect only the Android devices.

I have some public images that I'd like to load like this: <img src={imageurl} alt="" />

I'm using this plugin https://github.com/capacitor-community/http to make API calls, to avoid CORS issues. All the API calls are working on both platforms, but the images only works on iOS.

If I check the inspector this is the error message I get:

enter image description here

If I check the Android Studio logs I see these error messages: E/Capacitor: Unable to open asset URL:

If I'm using axios to make the API calls it works fine on Android but then it'll break on iOS due to CORS issues.

I was trying to separate the API calls and only use the native plugin on iOS but I don't think that is possible.. Android was able to make the calls with axios but response was always got response like this:

enter image description here

Android AndroidManifest is extended with this: android:usesCleartextTraffic="true"

webDir: "build",
bundledWebRuntime: false,
android: {
  allowMixedContent: true
},
server: {
  cleartext: true,
  hostname: "baseurl.hu",
  iosScheme: "localhost",
  androidScheme: "https"
},

This is how I run the app:

  1. ionic capacitor copy android
  2. Android Studio run.
0 Answers
Related