안드로이드
[ ionic ] net::ERR_CLEARTEXT_NOT_PERMITTED
mminky
2020. 7. 23. 15:05
728x90
안드로이드 sdk ver.28 부터는 텍스트로 url을 접근하는 것이 막혔다고 합니다.
AVD 시뮬레이터로 실행하니 다음과 같은 에러가 발생했습니다.
net::ERR_CLEARTEXT_NOT_PERMITTED
[config.xml]
<platform name="android">
<edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application" xmlns:android="http://schemas.android.com/apk/res/android">
<application android:networkSecurityConfig="@xml/network_security_config" />
<!-- cleartextTraffic 허용 -->
<application android:usesCleartextTraffic="true" />
</edit-config>
<application android:usesCleartextTraffic="true" /> 부분을 추가했습니다.
[network_security_config.xml]
(resources/android/xml/network_secutiry_config.xml)
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<domain-config cleartextTrafficPermitted="true">
<!-- 이부분 추가 -->
<trust-anchors>
<certificates src="system" />
</trust-anchors>
<domain includeSubdomains="true">localhost</domain>
<!-- 허용할 사이트 추가 -->
<domain includeSubdomains="true">google.com</domain>
<domain includeSubdomains="true">youtube.com</domain>
</domain-config>
</network-security-config>
다음의 코드들을 추가했습니다.
<trust-anchors>
<certificates src="system" />
</trust-anchors>
허용할 사이트를 추가했습니다.(구글, 유튜브)
이 때 http를 뺀 주소로 적습니다.
<domain includeSubdomains="true">google.com</domain>
<domain includeSubdomains="true">youtube.com</domain>
반응형