Alex
01/15/2025, 4:14 PMjava.net.UnknownServiceException: CLEARTEXT communication to 10.0.2.2 not permitted by network security policy
Any help would be appreciated.Alex
01/15/2025, 4:14 PM<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<base-config cleartextTrafficPermitted="true" />
<domain-config cleartextTrafficPermitted="true">
<domain includeSubdomains="true">10.0.2.2</domain>
</domain-config>
</network-security-config>
Alex
01/15/2025, 4:14 PMChrimaeon
01/15/2025, 4:21 PMAlex
01/15/2025, 4:23 PMChrimaeon
01/15/2025, 4:33 PMclearTextTraffic
. attribute on the <application>
that you can override in a debug builds manifest file.Alex
01/15/2025, 4:34 PMandroid:usesCleartextTraffic="true"
to the application tag in the manifest, building only debug but the error persistsChrimaeon
01/15/2025, 4:46 PM<network-security-config xmlns:tools="<http://schemas.android.com/tools>">
<base-config
cleartextTrafficPermitted="true"
tools:ignore="InsecureBaseConfiguration" />
</network-security-config>
in my app/src/debug/AndroidManifest.xml
referenced and this worksAlex
01/15/2025, 4:54 PMtools:
tag which should be irrelevant.
I have made it work by installing a https proxy (npm local-ssl-proxy), proxying a https endpoint to the http endpoint internally and by installing a trust all certs and domains trust manager on the OkHttp client side.
This works well enough for my usecase, since ktor and the android system now thinks I am accessing a https endpoint.
I am not sure why this does not work with the network security config, nothing obvious comes to mind.Viktor Nyblom
01/16/2025, 6:43 AMAlex
01/17/2025, 11:27 AM