Reputation: 43
I have read quite a few resources and tutorials so far, and I still haven't found the solution I need. The problem is that my application using Retrofit 2 does not send requests to my own server. Empirically, it was revealed that requests are not sent only to addresses using http. Requests were sent to https.
As a solution to this problem, I added the SSL key to my server (My server is written on Spring). Now requests are at least being sent. However, due to the fact that the key that I generated is not confirmed, the application still does not want to make requests for the links I need.
Question: how can you configure Retrofit 2 so that it works with http?
UPD: there is repo with some code from project:https://github.com/Parocq/AuthScreenApp
Upvotes: 1
Views: 1453
Reputation: 48
I took a look at the retrofit documentation https://square.github.io/retrofit/, and also did a quick look at their source code, and as far as I could see there is really nothing in there that cares about HTTP vs HTTPS.
I would suggest trying your app on a device or emulator running a pre-Pie version of Android, just to verify that everything works as expected with your plain HTTP requests. If it does, then I think the next step is to double-check your network security configuration, as suggested by @Bek. In case you have not found this article yet, here is a good place to start: https://developer.android.com/training/articles/security-config
I'm know this is at best a 'partial answer' (if even that) but I decided to post it based on the SO answer tips. I hope it can at least help you get unstuck or help you improve your question, and can be updated at some point with actual specific information on your question.
Update: Looks like you found the real answer, that was quick! https://stackoverflow.com/a/65751722/1245561
Upvotes: 1
Reputation: 43
Problem was solved with enabling cleartext traffic in manifest. Two strings was added: xmlns:tools="http://schemas.android.com/tools" and android:usesCleartextTraffic="true"
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.xxx.xxx.xxx">
<application
...
android:usesCleartextTraffic="true"
...
</application></manifest>
Upvotes: 2