我正在尝试实施sample android app provided here.
我按照指示安装了所有依赖项,但是当我在实际手机上运行代码时,错误消息表明(我认为!)方法setCoookieStore()
不存在并且导致问题在路上。这实际上是 AsyncHttpClient 的问题,还是这应该在父类中完成?我该如何解决?
我尝试过谷歌搜索相当多,但大多数结果似乎并不相关,而且经常是我的头脑(Android开发初学者......)。这似乎是我能找到的最接近的东西,但我不确定它是否正确或如何实现它:Using Cookies across Activities when using HttpClient。
感谢您的帮助!
<小时/> 这是错误消息的整个系列
04-29 05:58:24.386 6867-6867/? E/Zygote: MountEmulatedStorage()
04-29 05:58:24.386 6867-6867/? E/Zygote: v2
04-29 05:58:24.386 6867-6867/? E/Zygote: accessInfo : 0
04-29 05:58:24.386 6867-6867/? E/SELinux: [DEBUG] get_category: variable seinfo: default sensitivity: NULL, cateogry: NULL
04-29 05:58:25.066 6867-6867/com.empatica.empalinksample E/EMPA_C: Loaded
04-29 05:58:25.086 6867-6867/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.empatica.empalinksample, PID: 6867
java.lang.NoSuchMethodError: No virtual method setCookieStore(Lorg/apache/http/client/CookieStore;)V in class Lcom/loopj/android/http/AsyncHttpClient; or its super classes (declaration of 'com.loopj.android.http.AsyncHttpClient' appears in /data/app/com.empatica.empalinksample-2/base.apk)
at com.empatica.empalink.EmpaDeviceManager.<init>(EmpaDeviceManager.java:180)
at com.empatica.empalink.EmpaDeviceManager.<init>(EmpaDeviceManager.java:166)
at com.empatica.sample.MainActivity.onCreate(MainActivity.java:64)
at android.app.Activity.performCreate(Activity.java:6550)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1120)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3108)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3263)
at android.app.ActivityThread.access$1000(ActivityThread.java:197)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1687)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:6897)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)
答案 0 :(得分:0)
显然我需要添加&#34; useLibrary 'org.apache.http.legacy'
&#34;到我应用的build.gradle
文件,并确保compileSdkVersion
和buildToolsVersion
指向23(而不是之前的21)。
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion '23.0.1'
useLibrary 'org.apache.http.legacy'
....