I\'m attempting to return some data from an API using OkHttpClient in com.squareup.okhttp. I\'ve run into a few errors that i have eventually been able to overcome but i can\'t
For error like "java.net.UnknownHostException: [hostname]"
The reason is your hostname is not in /etc/hosts, The solution is simple:
sudo vim /etc/hosts
change the line looks like:
127.0.0.1 localhost
to:
127.0.0.1 [hostname] localhost
Save and exit. If the problem still exist, may be you need to restart or run :
sudo ifconfig eth0 down&&sudo ifconfig eth0 up
Hope it can help you!