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

Amplitude not compliant with StrictMode in SDK >= 27 #156

Closed
Neamar opened this issue Feb 2, 2018 · 2 comments
Closed

Amplitude not compliant with StrictMode in SDK >= 27 #156

Neamar opened this issue Feb 2, 2018 · 2 comments

Comments

@Neamar
Copy link

Neamar commented Feb 2, 2018

When compiling with targetSDK 27, and running Android StrictMode, the app will logs Amplitude libraries using Untagged sockets:

Since some developers run their debug builds with .penaltyDeath(), this mean that any call to Amplitude will force close the app.

From what I understand of the issue, a simple call to TrafficStats.setThreadSocketTag() from the network thread should fix the issue.

StrictMode: null
  java.lang.Throwable: Untagged socket detected; use TrafficStats.setThreadSocketTag() to track all network usage
      at android.os.StrictMode.onUntaggedSocket(StrictMode.java:2012)
      at com.android.server.NetworkManagementSocketTagger.tag(NetworkManagementSocketTagger.java:78)
      at libcore.io.BlockGuardOs.tagSocket(BlockGuardOs.java:47)
      at libcore.io.BlockGuardOs.socket(BlockGuardOs.java:310)
      at libcore.io.IoBridge.socket(IoBridge.java:667)
      at java.net.PlainSocketImpl.socketCreate(PlainSocketImpl.java:116)
      at java.net.AbstractPlainSocketImpl.create(AbstractPlainSocketImpl.java:98)
      at java.net.Socket.createImpl(Socket.java:484)
      at java.net.Socket.getImpl(Socket.java:547)
      at java.net.Socket.setSoTimeout(Socket.java:1175)
      at okhttp3.internal.io.RealConnection.connectSocket(RealConnection.java:135)
      at okhttp3.internal.io.RealConnection.connect(RealConnection.java:108)
      at okhttp3.internal.http.StreamAllocation.findConnection(StreamAllocation.java:188)
      at okhttp3.internal.http.StreamAllocation.findHealthyConnection(StreamAllocation.java:127)
      at okhttp3.internal.http.StreamAllocation.newStream(StreamAllocation.java:97)
      at okhttp3.internal.http.HttpEngine.connect(HttpEngine.java:289)
      at okhttp3.internal.http.HttpEngine.sendRequest(HttpEngine.java:241)
      at okhttp3.RealCall.getResponse(RealCall.java:240)
      at okhttp3.RealCall$ApplicationInterceptorChain.proceed(RealCall.java:198)
      at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:160)
      at okhttp3.RealCall.execute(RealCall.java:57)
      at com.amplitude.api.AmplitudeClient.makeEventUploadPostRequest(AmplitudeClient.java:1772)
      at com.amplitude.api.AmplitudeClient$13.run(AmplitudeClient.java:1641)
      at android.os.Handler.handleCallback(Handler.java:790)
      at android.os.Handler.dispatchMessage(Handler.java:99)
      at android.os.Looper.loop(Looper.java:164)
      at android.os.HandlerThread.run(HandlerThread.java:65)
@djih
Copy link
Member

djih commented Feb 5, 2018

@Neamar thanks for reporting. We are following the thread here to see what Okhttp recommends: square/okhttp#3537

@haoliu-amp
Copy link
Contributor

I think it should not be an issue anymore.
Latest version 2.24.2: https://mvnrepository.com/artifact/com.amplitude/android-sdk/2.24.2

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

3 participants