Hello!
For days I tried to run an application that plays music, but it does not work on Android 9! works in everything else … iphone, android 8, 7 and 6 … but not in 9!
I broke my head trying to fix this and nothing happens … does anyone know anything?
thanks for read <3
1 Like
Did you manage to resolve this?
I am facing the same issue, audio simply does not play on Android 9 devices. When the exact same project is run from older Android devices, audio plays as expected.
Here are some more details:
a) ionic info
Ionic:
Ionic CLI : 5.2.3 (C:\Users\xxxxxx\AppData\Roaming\npm\node_modules\ionic)
Ionic Framework : ionic-angular 3.9.8
@ionic/app-scripts : 3.2.4
Cordova:
Cordova CLI : 9.0.0 (cordova-lib@9.0.1)
Cordova Platforms : android 8.0.0
Cordova Plugins : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 4.1.1, (and 16 other plugins)
Utility:
cordova-res : not installed
native-run : 0.2.8
System:
Android SDK Tools : 26.1.1 (D:\AndroidDevelopmentSDK)
NodeJS : v8.9.4 (D:\NodeJS\node.exe)
npm : 6.8.0
OS : Windows 10
b) media plugin:
cordova-plugin-media 5.0.3 "Media"
cordova-plugin-file 6.0.1 "File"
No idea what is going wrong here, as there are no exceptions / errors thrown.
The issue happens when playing a stream from url.
There’s hardly any info available on this error, so I submitted a bug report here:
Finally figured this out. Since this only occurs on Android 9 (Pie), it has to do with the Network Security Configuration. Android P, unlike its predecessors now uses HTTPS by default, but my app was streaming music via HTTP.
If you use API 28 as target API level, this security can be overridden by changing the app code as follows:
In AndroidManifest.xml:
<application
...
android:usesCleartextTraffic="true">
....
</application>
If you don’t want to touch the manifest file, you can make the change via the config.xml file, under the <platform name="android">
tag.
<edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application" xmlns:android="http://schemas.android.com/apk/res/android">
<application android:usesCleartextTraffic="true" />
</edit-config>
Note: this overrides all HTTP requests. There is a solution method possible to only whitelist certain IPs or domains in the network_security_config.xml file, if needed.
More info:
1 Like