Hello developer, in this tutorial I will solve the problem of uselibrary Org Apache HTTP legacy not working Android Studio. Hope this article helps you to solve your problem. If you found it helpful, then bookmark this site and subscribe our YouTube Channel.
uselibrary Org Apache HTTP legacy not working
Step 1 :
Paste the below code in your build.gradle(:app) file inside defaultConfig { paste here } tag.
useLibrary 'org.apache.http.legacy'
Step 2 :
create a file inside res/xml folder give name network_security_config.xml and paste the below code inside it.
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<domain-config cleartextTrafficPermitted="true">
<domain includeSubdomains="true">your.website.domain</domain> <!-- the domain you are using for api network call -->
</domain-config>
</network-security-config>
Step 3 :
Paste the below code in AndroidManifest.xml file inside application tag where you declare activities.
<!-- Paste this inside <application tag-->
<uses-library
android:name="org.apache.http.legacy"
android:required="false"/>
Step 4 :
Add the below code also in the AndroidManifest.xml file inside application tag where you set you app icon and theme. Just paste this line there.
android:networkSecurityConfig="@xml/network_security_config"
Do not forget to add required permissions like Internet permission and Access network State permissions. You must have to add internet permission for using http server in the project.
Thank you for visiting our site and hope this tutorial really helps you. If you face any problem when using this code or any other problem related to Android Studio you can contact me or comment below. I will try to help you as soon as possible.
0 Comments