Header Ads

Header ADS

Cleartext HTTP traffic not permitted (Android Studio)

 

Cleartext HTTP traffic not permitted :

 Following solution allow you to set the protocol (HTTP / HTTPS) per ENVIRONMENT.

This way you are able to use http for your DEV-Environment, and https for your PRODUCTION-Environment, without the need to change it all the time! And this is needed, because generally you don't have an https-certificate for your local or dev environment, but it's a MUST-HAVE for production (and maybe for staging) environments.

But you can add additional directories to overwrite your AndroidManifest.xml. Here is how it works:
  • Create the Directory /app/src/debug
  • Inside create the AndroidManifest.xml
AndroidManifest.xml
 android:usesCleartextTraffic="true"
 
Here an Example how it looks like for the requested CLEARTEXT-Permission:
package="com.yourappname">  
   <application  
       android:usesCleartextTraffic="true"  
       android:name=".MainApplication"  
       android:label="@string/app_name"  
       android:icon="@mipmap/ic_launcher"  
       android:allowBackup="false"  
       android:theme="@style/AppTheme">  
   </application>  
 </manifest>

No comments

Powered by Blogger.