Android Apps make an HTTP request.

The error message:

"Invalid credentials or API error: Cleartext HTTP traffic to main4.knit.com.my not permitted."

means your app is trying to make an HTTP (not HTTPS) request, and Android is blocking it due to security restrictions starting with Android 9 (API level 28) and above.

How to Fix It

  1. In React Native, android/app/src/main/AndroidManifest.xml, inside the <application> tag, add:

  2.  <application
            android:usesCleartextTraffic="true"
  3. Create a file android/app/src/main/res/xml/network_security_config.xml

  4. xml
    <network-security-config> <domain-config cleartextTrafficPermitted="true"> <domain includeSubdomains="true">main4.knit.com.my</domain> </domain-config> </network-security-config>
  5. In your AndroidManifest.xml, inside <application>

  6.     <application
            android:networkSecurityConfig="@xml/network_security_config"
Sample


After Changes

If you update any manifest or security config:

cd android
./gradlew clean
cd ..
npx react-native run-android


Make sure your file has content.



Comments

Popular posts from this blog

To Enable IIS HTTPS on your website