I am getting this error while using volly library in my android studio projecte while running the app in my emulator and real deivce ! How can i resolve this!
CodePudding user response:
This error is coming because you had forgotten to connect your emulator / mobile device to the internet. Make Sure that your Internet or Wifi will be enabled! Because this type of library like volley needs internet Connection.
REASONS:-
Your Mobile / Emulator is not connected to the Internet
You had not been given Internet and Network state Permission in the Android Manifest File :
Paste the below code in the android manifest file.
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
NOTE:- This tag should be placed BEFORE the application TAG. If you put if after application TAG, it produces a warning.
MANIFEST FILE AFTER ADDING CODE
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="app.com.example.android.sunshine" >
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
Thanks!