okhttp3

Retrofit java.net.ProtocolException: Expected ':status' header not present

故事扮演 提交于 2019-12-11 02:44:55
问题 Retrofit network calls fails with a Protocol Exception suddenly in a working app. The app was working till yesterday and today all the network calls fails. The calls works fine with HTTP and with some HTTPS except my production endpoint . It seems that app is not working only on my used https endpoint but working with other https endpoint, I tried. I fixed the problem this way - OkHttpClient client = new OkHttpClient(); client.setProtocols(Arrays.asList(Protocol.HTTP_1_1)); And And my problem

OkHttp Authenticator sometimes does not call authenticate with multiple Retrofit instances

ⅰ亾dé卋堺 提交于 2019-12-11 00:22:45
问题 I have two different Retrofit instances for two different APIs. I also have two different OkHttp3 clients but they share the same Authenticator because the auth token is the same for both APIs. The problem is that when the token expires then sometimes (but almost always) one of the Retrofit / OkHttpClient objects will not call the Authenticator 's authenticate method on HTTP 401. It will happily make API calls and all will end with 401 and the authenticator is completely ignored. In this case

Caching error with Retrofit 2 and okhttp 3

橙三吉。 提交于 2019-12-11 00:18:46
问题 I'm trying to cache HTTP responses from my company API but it looks like the app cannot access the cache directory: W/System.err: remove failed: ENOENT (No such file or directory) : /data/user/0/com.appname/cache/cache_file/journal.tmp W/System.err: java.net.UnknownHostException: Unable to resolve host "www.domain.com": No address associated with hostname I have followed this tutorial. Here is how I setup Retrofit (2.1.0): import lu.CompanyName.R; import lu.CompanyName.interfaces

Add headers to request using Retrofit 2

主宰稳场 提交于 2019-12-10 23:45:41
问题 I'm trying to send requests with authentication headers, but it seems that the server cannot identify the client. I used this tutorial, and implemented an interceptor as follows: public class AuthenticationInterceptor implements Interceptor { private String authId; private String authToken; public AuthenticationInterceptor(String authId, String authToken) { this.authId = authId; this.authToken = authToken; } @Override public Response intercept(@NonNull Chain chain) throws IOException {

Retrofit2 HttpLoggingInterceptor Logcat

烂漫一生 提交于 2019-12-10 21:44:37
问题 Probably a novice question but I'm wondering where I actually catch the logs in log cat. Is there a particular place I put a log, a special regex to use etc. This is what my interceptor looks like: HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor(); interceptor.setLevel(HttpLoggingInterceptor.Level.BODY); OkHttpClient okClient = new OkHttpClient.Builder().addInterceptor(interceptor).build(); // Retrofit setup Retrofit client = new retrofit2.Retrofit.Builder() .baseUrl(BASE_URL)

How to send string array data with okhttp MultipartBuilder data

不想你离开。 提交于 2019-12-10 18:32:16
问题 I am an android developer. I develop an application. I have a problem. I want to send string array data with okhttp multipart data. But I can not do it. Because "addFormDataPart" method is required string variable. I can not use that method(addFormDataPart). I want to send string array data. What can I do? Please help me. My source code: private void String sendData(String serverURL, String[] arrayData){ RequestBody requestBody; requestBody = new MultipartBuilder() .type(MultipartBuilder.FORM

MissingResourceException: Can't find bundle for base name sun.util.logging.resources.logging, locale en_US

泄露秘密 提交于 2019-12-10 14:25:15
问题 I am getting, Caused by java.lang.InternalError: java.util.MissingResourceException: Can't find bundle for base name sun.util.logging.resources.logging, locale en_US in my application from firebase crash report. Other details Manufacturer: HTC Model: HTC 10 Android API: 24 Here is the stack trace java.util.logging.Logger$1.run (Logger.java:1385) java.util.logging.Logger$1.run (Logger.java:1379) java.security.AccessController.doPrivileged (AccessController.java:41) java.util.logging.Logger

OkHttp support for SDK versions less than 21

泄露秘密 提交于 2019-12-10 04:04:39
问题 OkHttp has recently dropped support for Android 4, except via a separate 3.12.x branch that will be supported until end of Dec 2020 (and probably receive no more than critical updates or bugfixes). On the assumption that you wish to continue to support Android 4, like I do, since 10% of the Android user base is still a significant proportion, and don't want to be stuck in a dead-end branch... Rather than being stuck on the 3.12.x branch for all sdk versions, is there any way of using the 3.12

Several new Proguard issues Google Play services v10.2.6 to v11.0.0 in a Multidex project

做~自己de王妃 提交于 2019-12-10 03:23:02
问题 I updated our app to use the most recent Android Firebase SDK v11.0.0 (https://firebase.google.com/support/release-notes/android#20170607) and out of the suddenly we bunch of new proguard errors appear, FYI everything was working well before with proguard. Before: compile 'com.google.firebase:firebase-messaging:10.2.6' compile 'com.google.android.gms:play-services-vision:10.2.6' After: compile 'com.google.firebase:firebase-messaging:11.0.0' compile 'com.google.android.gms:play-services-vision

How to resolve D8 warning: D8: Type `org.conscrypt.Conscrypt` was not found

时光总嘲笑我的痴心妄想 提交于 2019-12-09 08:06:57
问题 /Volumes/SSD/.gradle/caches/modules-2/files-2.1/com.squareup.okhttp3/okhttp/3.10.0/7ef0f1d95bf4c0b3ba30bbae25e0e562b05cf75e/okhttp-3.10.0.jar: D8: Type `org.conscrypt.Conscrypt` was not found, it is required for default or static interface methods desugaring of `okhttp3.internal.platform.Platform okhttp3.internal.platform.ConscryptPlatform.buildIfSupported()` 回答1: I was able to solve the problem with adding: -dontwarn okhttp3.internal.platform.ConscryptPlatform to the proguard-rules.pro file.