java.net.SocketException: Permission denied (maybe missing INTERNET permission)
Solution
In order to access the internet in your app, add the below line in your AndroidManifest.xml that will solve the internet permission.
<uses-permission android:name="android.permission.INTERNET" />
Please paste the above line before the <application> tag otherwise it will give warning.
Note: The permission name is case-sensitive i.e wrong case means your application does not get the internet permission.
WRONG
<uses-permission android:name="ANDROID.PERMISSION.INTERNET" />
STEPS:
1. Follow the below steps. Go to app -> src -> main -> AndroidManifest.xml
2. Add the following line in AndroidManifest.xml before <application> tag.
<uses-permission android:name="android.permission.INTERNET" />
3. Your AndroidManifest.xml file should look like this:
<manifest xlmns:android="http://schemas.android.com/apk/res/android" package="com.javahungry.helloworldapp"> ... <uses-permission android:name="android.permission.INTERNET" /> <application> ... </application> </manifest>
That's it. After performing the above steps you will be able to access the internet in the app. Please let me know in the comments in case you have any questions related to how to add internet permission in AndroidManifest.xml in Android Studio.