请帮助我如何在 android 应用程序中实现 Mashape 的 Zilyo API。
我正在将 Zilyo Mashape API 集成到 Android 应用程序中。但我遇到了一些错误。
这是我的代码。
try {
request = Unirest.get("https://zilyo.p.mashape.com/search?isinstantbook=true&nelatitude=22.37&nelongitude=-154.48000000000002&provider=airbnb%2Chousetrip&swlatitude=18.55&swlongitude=-160.52999999999997")
.header("X-Mashape-Key", "PtYDw5a2WEmshZZXBZRIFMR9WIxOp1jHYzRjsnOPWqZO7PMRTy")
.header("Accept", "application/json")
.asJson();
} catch (UnirestException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
构建.gradle
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.android.support:design:23.3.0'
compile 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2'
compile project(':unirest-java-1.3.21')
LogCat 错误
06-22 12:24:25.655 12799-19685/com.trs.jupit E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #4
06-22 12:24:25.655 12799-19685/com.trs.jupit E/AndroidRuntime: java.lang.RuntimeException: An error occured while executing doInBackground()
06-22 12:24:25.655 12799-19685/com.trs.jupit E/AndroidRuntime: at android.os.AsyncTask$3.done(AsyncTask.java:299)
06-22 12:24:25.655 12799-19685/com.trs.jupit E/AndroidRuntime: at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:352)
06-22 12:24:25.655 12799-19685/com.trs.jupit E/AndroidRuntime: at java.util.concurrent.FutureTask.setException(FutureTask.java:219)
06-22 12:24:25.655 12799-19685/com.trs.jupit E/AndroidRuntime: at java.util.concurrent.FutureTask.run(FutureTask.java:239)
06-22 12:24:25.655 12799-19685/com.trs.jupit E/AndroidRuntime: at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
06-22 12:24:25.655 12799-19685/com.trs.jupit E/AndroidRuntime: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
06-22 12:24:25.655 12799-19685/com.trs.jupit E/AndroidRuntime: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
06-22 12:24:25.655 12799-19685/com.trs.jupit E/AndroidRuntime: at java.lang.Thread.run(Thread.java:841)
06-22 12:24:25.655 12799-19685/com.trs.jupit E/AndroidRuntime: Caused by: java.lang.NoClassDefFoundError: org.apache.http.client.config.RequestConfig
06-22 12:24:25.655 12799-19685/com.trs.jupit E/AndroidRuntime: at com.mashape.unirest.http.options.Options.refresh(Options.java:45)
06-22 12:24:25.655 12799-19685/com.trs.jupit E/AndroidRuntime: at com.mashape.unirest.http.options.Options.<clinit>(Options.java:34)
06-22 12:24:25.655 12799-19685/com.trs.jupit E/AndroidRuntime: at com.mashape.unirest.http.HttpClientHelper.prepareRequest(HttpClientHelper.java:154)
06-22 12:24:25.655 12799-19685/com.trs.jupit E/AndroidRuntime: at com.mashape.unirest.http.HttpClientHelper.request(HttpClientHelper.java:131)
06-22 12:24:25.655 12799-19685/com.trs.jupit E/AndroidRuntime: at com.mashape.unirest.request.BaseRequest.asJson(BaseRequest.java:68)
06-22 12:24:25.655 12799-19685/com.trs.jupit E/AndroidRuntime: at com.trs.jupit.Stay$DownloadJSON.doInBackground(Stay.java:163)
06-22 12:24:25.655 12799-19685/com.trs.jupit E/AndroidRuntime: at com.trs.jupit.Stay$DownloadJSON.doInBackground(Stay.java:152)
06-22 12:24:25.655 12799-19685/com.trs.jupit E/AndroidRuntime: at android.os.AsyncTask$2.call(AsyncTask.java:287)
06-22 12:24:25.655 12799-19685/com.trs.jupit E/AndroidRuntime: at java.util.concurrent.FutureTask.run(FutureTask.java:234)
06-22 12:24:25.655 12799-19685/com.trs.jupit E/AndroidRuntime: at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
06-22 12:24:25.655 12799-19685/com.trs.jupit E/AndroidRuntime: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
06-22 12:24:25.655 12799-19685/com.trs.jupit E/AndroidRuntime: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
06-22 12:24:25.655 12799-19685/com.trs.jupit E/AndroidRuntime: at java.lang.Thread.run(Thread.java:841)