I'm developing an app with IONIC 4.0 (Angular). The app is completely okay while I am running the APK file in android Orio (8.0). But unfortunately, it shows the following problem when I am getting to log in Android PIE (9.0).

- 81,827
- 26
- 193
- 197
- 1,364
- 4
- 15
- 34
-
Please tell more about your Api server to let you understand how to do the self signed cert. – Elias Soares Jun 12 '19 at 11:00
3 Answers
I had the same problem with Android 9, it was confused but with a little research, I found new features about the new Android version, here you'll found the solution:
According to Network security configuration
Option 1 -
Create file res/xml/network_security_config.xml - `
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<domain-config cleartextTrafficPermitted="true">
<domain includeSubdomains="true">Your URL(ex: 127.0.0.1)</domain>
</domain-config>
</network-security-config>
`
On your AndroidManifest.xml -
<?xml version="1.0" encoding="utf-8"?>
<manifest ...>
<uses-permission android:name="android.permission.INTERNET" />
<application
...
android:networkSecurityConfig="@xml/network_security_config"
...>
...
</application>
</manifest>
Option 2 -
android:usesCleartextTraffic Doc
On your AndroidManifest.xml -
<?xml version="1.0" encoding="utf-8"?>
<manifest ...>
<uses-permission android:name="android.permission.INTERNET" />
<application
...
android:usesCleartextTraffic="true"
...>
...
</application>
</manifest>
Its works perfectly for me :)
- 365
- 2
- 7
-
1The text of your answer doesn't answer the question, and the linked page may disappear. Please summarize or include the relevant information from the linked page in your answer. – Preacher Jul 09 '19 at 23:15
-
Sorry, it was my first post, many thanks for the comment @Preacher – Marco Chavez Jul 10 '19 at 14:52
-
open your config.xml file
Add this line to Widget tag
xmlns:android="http://schemas.android.com/apk/res/android"
under the platform android section add the below line
<edit-config file="AndroidManifest.xml" mode="merge" target="/manifest/application">
<application android:usesCleartextTraffic="true" />
</edit-config>
This is worked for me.
- 1
- 2
That's happens because since Android Pie, you cannot make non secure http requests. There's some what's to workaround it, but I've found no one that works on Ionic/Cordova.
That's a pain, but you will need to add a self signed ask cert to your Api server, add it to trust store on Android and with luck it will work.
I'm writing from mobile now, but as soon as possible I'll update my answer to add some references.
- 9,884
- 4
- 29
- 59