0

我有一个问题,但找不到任何解决方案,我在https://github.com/AsyncHttpClient/async-http-client中使用 AsyncHttpClient ,我可以在 API 级别 10 中运行我的代码,但不能在 API 级别 17 中运行。我收到此错误:

11-13 14:36:47.987  13294-13294/com.modilisim.antalyaticaretborsasi E/com.modilisim.antalyaticaretborsasi.view.fragment.ScrollingBultenlerFragment﹕ error occurred while getting daily bultenler
java.util.concurrent.ExecutionException: java.net.ConnectException: http://...
        at com.ning.http.client.providers.netty.NettyResponseFuture.abort(NettyResponseFuture.java:328)
        at com.ning.http.client.providers.netty.NettyConnectListener.operationComplete(NettyConnectListener.java:106)
        at org.jboss.netty.channel.DefaultChannelFuture.notifyListener(DefaultChannelFuture.java:427)
        at org.jboss.netty.channel.DefaultChannelFuture.addListener(DefaultChannelFuture.java:145)
        at com.ning.http.client.providers.netty.NettyAsyncHttpProvider.doConnect(NettyAsyncHttpProvider.java:1056)
        at com.ning.http.client.providers.netty.NettyAsyncHttpProvider.execute(NettyAsyncHttpProvider.java:880)
        at com.ning.http.client.AsyncHttpClient.executeRequest(AsyncHttpClient.java:521)
        at com.ning.http.client.AsyncHttpClient$BoundRequestBuilder.execute(AsyncHttpClient.java:238)
        at com.modilisim.antalyaticaretborsasi.presenter.BultenPresenter.getDailyBultenler(BultenPresenter.java:126)
        at com.modilisim.antalyaticaretborsasi.presenter.BultenPresenter.getDailyBultenler(BultenPresenter.java:102)
        at com.modilisim.antalyaticaretborsasi.view.fragment.ScrollingBultenlerFragment.onCreateView(ScrollingBultenlerFragment.java:51)
        at android.support.v4.app.Fragment.performCreateView(Fragment.java:1500)
        at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:900)
        at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1082)
        at android.support.v4.app.FragmentManagerImpl.addFragment(FragmentManager.java:1184)
        at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:291)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:676)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:749)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:749)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:749)
        at android.view.LayoutInflater.parseInclude(LayoutInflater.java:830)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:736)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
        at com.modilisim.antalyaticaretborsasi.view.fragment.MainFragment.onCreateView(MainFragment.java:42)
        at android.support.v4.app.Fragment.performCreateView(Fragment.java:1500)
        at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:927)
        at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1104)
        at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:682)
        at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1467)
        at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:570)
        at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1164)
        at android.app.Activity.performStart(Activity.java:5114)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2269)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2356)
        at android.app.ActivityThread.access$600(ActivityThread.java:150)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1244)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:137)
        at android.app.ActivityThread.main(ActivityThread.java:5195)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:511)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:795)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:562)
        at dalvik.system.NativeStart.main(Native Method)
 Caused by: java.net.ConnectException: http://...
        at com.ning.http.client.providers.netty.NettyConnectListener.operationCom

我在一家公司做一个项目,所以我不得不在上面的错误代码中隐藏 url,但是 url 正在工作,它们不是问题。任何帮助表示赞赏,谢谢。

4

1 回答 1

0

我了解到这个 AsyncHttpClient 库不适用于 Android,因此它不能在所有版本的 Android 上正常工作。有一个与此库并行的 Android 库:http: //loopj.com/android-async-http/

于 2014-03-28T13:12:21.413 回答