我正在尝试更新到com.loopj.android:android-async-http的最新版本(1.4.9),其中org.apache.http被cz.msebera.android.httpclient取代了.
目前,我使用:
StringEntity entity = new StringEntity("some data");
client.post(static_context, getAbsoluteUrl(url), entity, "application/json", responseHandler);
所以我想我可以将其强制转换为HttpEntity,事实并非如此.
Caused by: java.lang.ClassCastException: org.apache.http.entity.StringEntity cannot be cast to cz.msebera.android.httpclient.HttpEntity
所以我的问题是如何用我的数据创建HttpEntity还是有更好的方法用正文中的数据创建发布请求?
解决方法:
看起来您导入了错误的StringEntity类.
假设cz.msebera.android.httpclient仍然具有StringEntity,您应该能够
import cz.msebera.android.httpclient.entity.StringEntity
代替
import org.apache.http.entity.StringEntity
标签:loopj,java,android,android-async-http
来源: https://codeday.me/bug/1119/2035195.html