Android (9) Pie에서 모든 네트워크 연결 유형 HTTP 및 HTTPS를 허용하는 방법은 무엇입니까?
이제 Android 9 Pie에서 암호화가없는 요청은 작동하지 않습니다. 그리고 기본적으로 시스템은 기본적으로 TLS를 사용할 것으로 예상합니다. 여기에서이 기능을 읽을 수 있으므로 HTTPS를 통해서만 요청하면 안전합니다. 그러나 브라우저와 같은 앱과 같이 다른 사이트를 통해 요청하는 앱은 어떻습니까?
Android 9 Pie에서 모든 유형의 연결 HTTP 및 HTTPS에 대한 요청을 활성화하려면 어떻게해야합니까?
이를 구현하는 쉬운 방법 은 모든 요청에 대해 모두 AndroidManifest.xml
허용하는 위치 에이 속성을 사용 하는 것 http
입니다.
android:usesCleartextTraffic="true"
그러나 예를 들어 다른 링크에 대해 더 많은 구성 을 원할 경우 http
일부 도메인은 허용 하지만 다른 도메인은 허용 하지 않는 경우 networkSecurityConfig
파일을 제공해야 합니다.
Android 9 Pie에서이를 수행하려면 다음 과 같이 networkSecurityConfig
Manifest application
태그 에 를 설정해야합니다 .
<?xml version="1.0" encoding="utf-8"?>
<manifest ... >
<application android:networkSecurityConfig="@xml/network_security_config">
</application>
</manifest>
그런 다음 xml
폴더 에서 이제 network_security_config
매니페스트에서 이름을 지정한 것과 같은 이름의 파일을 만들어야하며 여기에서 암호화없이 모든 요청을 활성화하려면 파일 내용이 다음과 같아야합니다.
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<base-config cleartextTrafficPermitted="true">
<trust-anchors>
<certificates src="system" />
</trust-anchors>
</base-config>
</network-security-config>
거기에서 당신은 갈 수 있습니다. 이제 앱이 모든 유형의 연결을 요청합니다. 이 주제에 대한 추가 정보는 여기를 읽으십시오 .
완전히 작업 솔루션을 모두 Android
또는 React-native
이 문제에 직면 사용자는이 추가 android:usesCleartextTraffic="true"
같은의 AndroidManifest.xml 파일에 :
android:usesCleartextTraffic="true"
tools:ignore="GoogleAppIndexingWarning">
<uses-library
android:name="org.apache.http.legacy"
android:required="false" />
<application>
.. </application>
태그 사이에 다음 과 같이 :
<application
android:name=".MainApplication"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:allowBackup="false"
android:theme="@style/AppTheme"
android:usesCleartextTraffic="true"
tools:ignore="GoogleAppIndexingWarning">
<uses-library
android:name="org.apache.http.legacy"
android:required="false" />
<activity
android:name=".MainActivity"
android:label="@string/app_name"/>
</application>
간단한 방법이 설정 android:usesCleartextTraffic="true"
되어 있습니다.AndroidManifest.xml
android:usesCleartextTraffic="true"
Your AndroidManifest.xml
look like
<?xml version="1.0" encoding="utf-8"?>
<manifest package="com.dww.drmanar">
<application
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:usesCleartextTraffic="true"
android:theme="@style/AppTheme"
tools:targetApi="m">
<activity
android:name=".activity.SplashActivity"
android:theme="@style/FullscreenTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
I hope this will help you.
Just set usesCleartextTraffic
flag in the application tag of AndroidManifest.xml
file. No need to create config file for Android.
<application
android:usesCleartextTraffic="true"
.
.
.>
For React Native
applications while running in debug add the xml block
mentioned by @Xenolion to react_native_config.xml
located in <project>/android/app/src/debug/res/xml
Similar to the following snippet:
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<domain-config cleartextTrafficPermitted="true">
<domain includeSubdomains="false">localhost</domain>
<domain includeSubdomains="false">10.0.2.2</domain>
<domain includeSubdomains="false">10.0.3.2</domain>
</domain-config>
<base-config cleartextTrafficPermitted="true">
<trust-anchors>
<certificates src="system" />
</trust-anchors>
</base-config>
</network-security-config>
You may check if you are sending clearText through HTTP Fix : https://medium.com/@son.rommer/fix-cleartext-traffic-error-in-android-9-pie-2f4e9e2235e6
OR
In the Case of Apache HTTP client deprecation (From Google ) : With Android 6.0, we removed support for the Apache HTTP client. Beginning with Android 9, that library is removed from the bootclasspath and is not available to apps by default. To continue using the Apache HTTP client, apps that target Android 9 and above can add the following to their AndroidManifest.xml:
Source https://developer.android.com/about/versions/pie/android-9.0-changes-28
'development' 카테고리의 다른 글
Meteor 프로젝트에서 기존 MongoDB를 어떻게 사용합니까? (0) | 2020.09.18 |
---|---|
최대 절전 모드 주석의 @UniqueConstraint 및 @Column (unique = true) (0) | 2020.09.18 |
MsSQL에서 간단한 '찾기 및 바꾸기'를 수행하려면 어떻게합니까? (0) | 2020.09.18 |
Javascript에서 정규식 일치 수 계산 (0) | 2020.09.18 |
IntelliJ IDEA : 줄 이동? (0) | 2020.09.18 |