简体   繁体   English

Android - Jsoup 连接在模拟器上成功但在设备上失败

[英]Android - Jsoup connect succeeds on emulator but fails on device

When trying to login using Jsoup connect on a website (in order to retrieve cookies for future requests), the request works fine on the emulator but not on my device.当尝试在网站上使用 Jsoup connect 登录时(以便为将来的请求检索 cookie),该请求在模拟器上运行良好,但在我的设备上运行不正常。 Here is a piece of code :这是一段代码:

// login data passed as a body using application/xxx-form-urlencoded
Map<String, String> data = new HashMap<>();
Map<String, String> headers = new HashMap<>();
Connection conn = Jsoup.connect(login_url)
                .data(list)
                .headers(headers)
                .method(Connection.Method.POST)
                .ignoreHttpErrors(true);
Connection.Response res = conn.execute();

Everything is fine on the emulator : it returns a 200 with the cookies I am expecting.模拟器上的一切都很好:它返回 200 和我期待的 cookie。 On device it returns a 404 : according to some tests on Postman it means that the login fails, but I can't figure out why... Both connection parameters are identical.在设备上它返回 404 :根据对 Postman 的一些测试,这意味着登录失败,但我不知道为什么......两个连接参数是相同的。

The SDK version is ok, I tried with other methods (HttpUrlConnection) but it won't work either.. SDK版本没问题,我尝试了其他方法(HttpUrlConnection),但它也不起作用..

Is there something I am missing ?有什么我想念的吗?

Thanks for the help !谢谢您的帮助 !

我做了一个 HttpUrlConnection ,它解决了我的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Android Jsoup.connect(String).execute()失败 - Android Jsoup.connect(String).execute() fails 当我的android应用程序在android设备/模拟器上运行时Jsoup无法正常工作 - Jsoup is not working when my android application is running on android device/emulator 尝试与 android studio 中的 jsoup 连接时,模拟器应用程序崩溃 - emulator app crashes when trying to connect with jsoup in android studio 排球在模拟器上运行,但在设备上失败 - Volley runs on Emulator but fails on device Android模拟器无法启动::无法在设备“模拟器-5554”上安装apk:null - Android Emulator Fails To Launch :: Failed to install apk on device 'emulator-5554': null Android Jsoup Connect冻结线程 - Android Jsoup connect freezes thread JSOUP和Android模拟器-无法解析主机 - JSOUP and Android Emulator - unable to resolve host 集成测试无法连接,手动浏览器测试通过带有SpringBoot / Jsoup集成测试的Java RESTful Web服务成功 - Integration Tests fail to connect, Manual Browser Test succeeds with Java RESTful Web Service with SpringBoot/Jsoup Integration Test Firebase android 可以在模拟器上运行,但不能在设备上运行 - Firebase android works on the emulator but not on the device 在仿真器上工作但不在真正的Android设备上 - Working on Emulator but not on the real Android device
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM