Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Google Analytics/OkHttp conflict on Android #319

Closed
romainpiel opened this issue Sep 24, 2013 · 13 comments
Closed

Google Analytics/OkHttp conflict on Android #319

romainpiel opened this issue Sep 24, 2013 · 13 comments

Comments

@romainpiel
Copy link

Hey, I've just noticed a weird issue. I'm not sure it's related to Okhttp, Retrofit or Google Analytics but I'll post it here.

In my Android app I have a very simple screen performing autocomplete with google places API. This is done using Retrofit and Okhttp. Everything was working fine until I integrated Google Analytics v3. When the autocomplete requests were running (ie when the thread Spdy Reader maps.googleapis.com was spawn) an ANR was occurring once Google Analytics was sending its data. I fixed it by removing Okhttp and using the default client from retrofit.

I know its a pretty weird and random issue but I thought you might be interested by that result. I will post a sample to reproduce the issue.

The stacktrace is not very verbose, it just says the crash happened on Google Analytics' side (GAThread).

@swankjesse
Copy link
Member

Please post a sample and a stackdump.

@romainpiel
Copy link
Author

Will do asap

@ChristianKatzmann
Copy link
Contributor

Have a look at #184 . I had the same issue with GoogleAnalytics and OkHttp and solved it by adding a private SslSocketFactory to the used OkHttpClient as proposed here

@Richie97
Copy link

Richie97 commented Oct 1, 2013

I've tried the workarounds from #184, and it still segfaults.

@ChristianKatzmann
Copy link
Contributor

Could you please paste your code for Retrofit's RestAdapter creation?

@Richie97
Copy link

Richie97 commented Oct 1, 2013

I'm not using Retrofit, just OkHttp and Google Analytics.

@ChristianKatzmann
Copy link
Contributor

Ok, could you then post the OkHttpClient initialization code, please?

@Richie97
Copy link

Richie97 commented Oct 2, 2013

Currently it's:

OkHttpClient httpClient = new OkHttpClient();
SSLContext sslContext;
try {
     sslContext = SSLContext.getInstance("TLS");
     sslContext.init(null, null, null);
} catch (GeneralSecurityException e) {
     throw new AssertionError(); // The system has no TLS. Just give up.
}
httpClient.setSslSocketFactory(sslContext.getSocketFactory());
URL.setURLStreamHandlerFactory(httpClient);
return httpClient;

I've tried without adding the SSL Context to OkHttp, but Google Analytics still segfaults.

@swankjesse
Copy link
Member

@Richie97 that's strange. You're sure that's the only place OkHttp is being used?

@ChristianKatzmann
Copy link
Contributor

Do you use Picasso, maybe?

@Richie97
Copy link

Richie97 commented Oct 2, 2013

@swankjesse Ah, I had a library I made that also relied on OkHttp. Also adding the workarounds to that fixed the issue.

@JakeWharton
Copy link
Member

@Richie97 So you're saying this is a duplicate of #184? Can we close this issue then?

@Richie97
Copy link

2 months late, but yeah.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants