java - Android(9) पाई में सभी नेटवर्क कनेक्शन प्रकार HTTP और HTTPS की अनुमति कैसे दें?
kotlin android-9.0-pie (4)
आप चेक कर सकते हैं कि आप HTTP फिक्स के माध्यम से क्लीयर टेक्स्ट भेज रहे हैं:
https://medium.com/@son.rommer/fix-cleartext-traffic-error-in-android-9-pie-2f4e9e2235e6
या
अपाचे HTTP क्लाइंट के अपग्रेडेशन के मामले में (Google से): Android 6.0 के साथ, हमने Apache HTTP क्लाइंट के लिए समर्थन हटा दिया।
एंड्रॉइड 9 के साथ शुरू होने पर, वह लाइब्रेरी बूटक्लासपथ से हटा दी जाती है और डिफ़ॉल्ट रूप से ऐप्स के लिए उपलब्ध नहीं होती है।
अपाचे HTTP क्लाइंट का उपयोग जारी रखने के लिए, एंड्रॉइड 9 और इसके बाद के संस्करण वाले एप्लिकेशन अपने AndroidManifest.xml पर निम्न जोड़ सकते हैं:
स्रोत https://developer.android.com/about/versions/pie/android-9.0-changes-28
एंड्रॉइड 9 पाई से अब, एन्क्रिप्शन के बिना अनुरोध कभी काम नहीं करेंगे। और डिफ़ॉल्ट रूप से, सिस्टम आपसे डिफ़ॉल्ट रूप से TLS का उपयोग करने की अपेक्षा करेगा। आप इस सुविधा को यहां पढ़ सकते हैं, इसलिए यदि आप केवल HTTPS के माध्यम से अनुरोध करते हैं तो आप सुरक्षित हैं। लेकिन उन ऐप्स के बारे में जो विभिन्न साइटों के माध्यम से अनुरोध करते हैं, उदाहरण के लिए, ब्राउज़र जैसे ऐप।
मैं एंड्रॉइड 9 पाई में HTTP और HTTPS के सभी प्रकार के अनुरोधों को कैसे सक्षम कर सकता हूं?
इस समस्या का सामना
कर रहे
Android
या
React-native
उपयोगकर्ताओं दोनों के लिए
पूरी तरह से काम कर रहे समाधान
इस
android:usesCleartextTraffic="true"
जोड़ते हैं
android:usesCleartextTraffic="true"
का इस तरह से उपयोग करता है:
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"
सेट है
android:usesCleartextTraffic="true"
आप
AndroidManifest.xml
पर
android:usesCleartextTraffic="true"
करता है
android:usesCleartextTraffic="true"
आपका
AndroidManifest.xml
जैसा दिखता है
<?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>
उम्मीद है इससे आपको मदद मिलेगी।
डिबग में दौड़ते समय रिएक्टिव नेटिव एप्लिकेशन के लिए
react_native_config.xml
द्वारा बताए गए
xml block
को
react_native_config.xml
में जोड़ें
<project>/android/app/src/debug/res/xml
निम्नलिखित स्निपेट के समान:
<?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>