http
http copied to clipboard
Unable to open asset URL on Android
Describe the bug
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:
I'm using this plugin 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:
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 even it says 200 OK, the response is always like this instead of JSON:
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" },
To Reproduce Steps to reproduce the behavior:
- Add this plugin to your project
- Try to load external public images into an image
- on iOS it loads well, on Android it does not.
Expected behavior Images should load on both platform. I tried to load other public images and non of them worked for me. When I was using axios it worked fine.
Smartphone (please complete the following information):
- Device: Xiaomi Redmi 9
- OS: Android 10.0
Additional context I would be okay with both solutions, use axios on Android and native network calls for iOS OR make Android load images somehow.