I want to get datas from pokeAPI for my android API. I have followed the instructions into this page https://github.com/PokeAPI/pokekotlin.
I have add in bluid.gradle(module:app) dependencies :
compile 'me.sargunvohra.lib:pokekotlin:2.3.0'
In build.gradle(Project):
allprojects {
repositories {
google()
jcenter()
maven { url 'http://jcenter.bintray.com' }
}
}
I have add this permission in manifest :
<uses-permission android:name="android.permission.INTERNET" />
The code for get pokemon species is in a asynctask :
private class DownloadPokeAPIData extends AsyncTask<Integer,Void,PokemonSpecies> {
protected PokemonSpecies doInBackground(Integer...numbers){
PokeApi pokeApi = new PokeApiClient();
try {
return pokeApi.getPokemonSpecies(numbers[0].intValue());
}catch(Exception e){
Log.e("AsyncTask error",e.getMessage());
}
return null;
}
protected void onPostExecute(PokemonSpecies result) {
if(result != null) ((TextView)findViewById(R.id.pokemon)).setText(result.getName());
}
}
The call of DownloadPokeAPIData is in onCreate of MainActivity: new DownloadPokeAPIData().execute(new Integer(1));
But i still get this message:
AsyncTask error: Unable to resolve host "pokeapi.co": No address associated with hostname
Do you know where the problem came from ?