如何处理此java.lang.IllegalStateException
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
getCurrentdata();
}
});
}
private void getCurrentdata() {
String url = Serverfetcheddata.base_url+"data/2.5/weather?q="+ city_name.getText().toString() + "&appid=" +Serverfetcheddata.key;
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(Serverfetcheddata.base_url)
.addConverterFactory(GsonConverterFactory.create())
.build();
Serverfetcheddata serverfetcheddata = retrofit.create(Serverfetcheddata.class);
Call<Weather> weatherCall = serverfetcheddata.getCurrentWeatherData(url);
weatherCall.enqueue(new Callback<Weather>() {
@Override
public void onResponse(Call<Weather> call, Response<Weather> response) {
Weather weather = response.body();
fetch_data.setText(weather.getMain());
// fetch_data.setText(weather.getMain());
// Toast.makeText(MainActivity.this, "Success"+ " "+ response.body(), Toast.LENGTH_SHORT).show();
}
@Override
public void onFailure(Call<Weather> call, Throwable t) {
Log.d("CODE","Error Message :"+t.getMessage());
//fetch_data.setText(t.getMessage());
}
});
}
}
错误消息:java.lang.IllegalStateException:应为字符串,但为 第1行第133列的BEGIN_OBJECT路径$ .main