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

Android only - PlatformException(-120, Trouble initializing Branch. Task exceeded timeout., null, null) #406

Open
gabidev89 opened this issue Jan 4, 2025 · 7 comments
Labels
bug Something isn't working

Comments

@gabidev89
Copy link

gabidev89 commented Jan 4, 2025

Description
When app starts, there's a throw that occurs. after that the app deeplink data is clear , FlutterBranchSdk.getLatestReferringParams() fails to retrieve the data, also FlutterBranchSdk.listSession().listen is never triggered.
Everything works on iOS. Happens only on android.

Steps to reproduce
Steps to reproduce the behavior:

  1. Implement Flutter SDK for Android
  2. Run debug on Android
  3. Debug will pause due to SDK Throw
  4. Continue debug
  5. Try opening app from deeplink when app is in background
  6. Deeplink data is empty

Expected behavior
Init should complete without throwing on android, listener should be called when app is opened by deeplink

Screenshots
Screenshot 2025-01-04 at 20 23 56

Mobile:

  • Flutter: version: 3.24.5
  • flutter_branch_sdk version: 8.3.1
  • OS: Android 15
  • Device: Pixel 6A

Additional context
When link is clicked log shows the following:
D/FlutterBranchSDK( 2190): triggered onInitFinished
D/FlutterBranchSDK( 2190): BranchReferralInitListener - error: Trouble initializing Branch. Task exceeded timeout.
E/flutter ( 2190): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(-120, Trouble initializing Branch. Task exceeded timeout., null, null)
E/TRuntime.CctTransportBackend( 2190): Couldn't encode request, returning with 400
E/TRuntime.CctTransportBackend( 2190): javax.net.ssl.SSLHandshakeException: connection closed
E/TRuntime.CctTransportBackend( 2190): at com.android.org.conscrypt.SSLUtils.toSSLHandshakeException(SSLUtils.java:358)

@gabidev89 gabidev89 added the bug Something isn't working label Jan 4, 2025
@RodrigoSMarques
Copy link
Owner

When opening an issue, fill in all the requested information.

Do not delete any sessions.

Without this information, it is not possible to analyze the problem in detail and reproduce it.

If the requested information is not provided, the issue will be closed.

@gabidev89
Copy link
Author

Requested info was edited in, is there a fix on the way? any suggestions how can i workaround the issue? branch sdk completely crashes on android...

@RodrigoSMarques
Copy link
Owner

RodrigoSMarques commented Jan 6, 2025

Are you running from an emulator?

Have you given internet permission in the AndroidManifest.xml for the app?

Have you checked if the device has internet access? Can it access pages via the browser?

This error message is returned by the Branch SDK, not the Flutter plugin.

Open a support ticket for Branch at the link or open an issue in the platform repository:

@gabidev89
Copy link
Author

gabidev89 commented Jan 6, 2025

  • Multiple real devices, samsung and pixel.
  • Manifest has :
    <uses-permission android:name="android.permission.INTERNET" />
  • App is running and working with server, no connectivity issues.

Is there any other required configuration for android support beside what is described in the readme that might be required.
Everything worked before...

@RodrigoSMarques
Copy link
Owner

Ad blockers interfere with the SDK's operation. I don't know if this is the case.

As I mentioned above. This is a message returned by the Native SDK.

I suggest you contact the Branch support team.

@gabidev89
Copy link
Author

I've contacted the native team but no response...
I've updated to 8.3.2, there's a lot more logging...

D/FlutterBranchSDK(17786): triggered onAttachedToEngine
D/FlutterBranchSDK(17786): triggered setupChannels
D/FlutterBranchSDK(17786): SDK Init
D/FlutterBranchSDK(17786): triggered onAttachedToActivity
D/FlutterBranchSDK(17786): triggered setActivity
D/FlutterBranchSDK(17786): triggered onActivityStarted: ...
D/FlutterBranchSDK(17786): triggered SessionBuilder init
D/FlutterBranchSDK(17786): triggered onActivityResumed: ...

D/FlutterBranchSDK(17786): triggered setupBranch
I/BranchSDK(17786): !SDK-VERSION-STRING!:io.branch.sdk.android:library:5.15.0
V/BranchSDK(17786): disableTracking context: android.app.Application@16e319e disableTracking: false callback: null
V/BranchSDK(17786): Set Consumer Protection Preference to FULL
D/FlutterBranchSDK(17786): notifyNativeToInit()
V/BranchSDK(17786): notifyNativeToInit deferredSessionBuilder io.branch.referral.Branch$InitSessionBuilder@ae6b15c
V/BranchSDK(17786): Beginning session initialization
V/BranchSDK(17786): Session uri is null
V/BranchSDK(17786): Callback is br.com.rsmarques.flutter_branch_sdk.FlutterBranchSdkPlugin$1@1c713cf
V/BranchSDK(17786): Is auto init false
V/BranchSDK(17786): Will ignore intent null
V/BranchSDK(17786): Is reinitializing false
V/BranchSDK(17786): isInstantDeepLinkPossible false
V/BranchSDK(17786): ServerRequest constructor
V/BranchSDK(17786): setPost {}
D/BranchSDK(17786): Creating io.branch.referral.ServerRequestRegisterInstall@ec5b417 from init on thread main
V/BranchSDK(17786): initializeSession io.branch.referral.ServerRequestRegisterInstall@ec5b417 delay 0
V/BranchSDK(17786): Intent: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x30000000 cmp=/.MainActivity (has extras) } forceBranchSession: false initState: UNINITIALISED
V/BranchSDK(17786): registerAppInit io.branch.referral.ServerRequestRegisterInstall@ec5b417
V/BranchSDK(17786): Ordering init calls
V/BranchSDK(17786): Queue is:
V/BranchSDK(17786): Moving io.branch.referral.ServerRequestRegisterInstall@ec5b417 to front of the queue or behind network-in-progress request
V/BranchSDK(17786): Finished ordering init calls
V/BranchSDK(17786): Queue is: io.branch.referral.ServerRequestRegisterInstall@ec5b417 with locks []
V/BranchSDK(17786): initTasks io.branch.referral.ServerRequestRegisterInstall@ec5b417
V/BranchSDK(17786): Added INSTALL_REFERRER_FETCH_WAIT_LOCK
V/BranchSDK(17786): Begin fetchInstallReferrer
V/BranchSDK(17786): Added GAID_FETCH_WAIT_LOCK
V/BranchSDK(17786): Begin fetchGoogleAdId
V/BranchSDK(17786): processNextQueueItem registerAppInit
V/BranchSDK(17786): Queue is: io.branch.referral.ServerRequestRegisterInstall@ec5b417 with locks [INSTALL_REFERRER_FETCH_WAIT_LOCK, GAID_FETCH_WAIT_LOCK]
D/BranchSDK(17786): processNextQueueItem, req io.branch.referral.ServerRequestRegisterInstall@ec5b417
D/BranchSDK(17786): No Facebook App ID provided. Can't check for Meta Install Referrer
W/BranchSDK(17786): Caught getSamsungGalaxyStoreReferrerDetails onInstallReferrerSetupFinished response code: 2
D/AdvertisingIdClient(17786): AdvertisingIdClient already created.
W/BranchSDK(17786): Caught getSamsungGalaxyStoreReferrerDetails response code: 2
V/BranchSDK(17786): Could not find com.huawei.hms.ads.installreferrer.api.InstallReferrerClient. If expected, import the dependency into your app.
V/BranchSDK(17786): Could not find com.miui.referrer.api.GetAppsReferrerClient. If expected, import the dependency into your app.
V/BranchSDK(17786): processNextQueueItem onAdsParamsFetchFinished
V/BranchSDK(17786): Queue is: io.branch.referral.ServerRequestRegisterInstall@ec5b417 with locks [INSTALL_REFERRER_FETCH_WAIT_LOCK]
D/BranchSDK(17786): processNextQueueItem, req io.branch.referral.ServerRequestRegisterInstall@ec5b417
D/FlutterBranchSDK(17786): triggered onAttachedToEngine
D/FlutterBranchSDK(17786): triggered setupChannels
D/FlutterBranchSDK(17786): SDK Init
W/BranchSDK(17786): Caught getGooglePlayStoreReferrerDetails onInstallReferrerSetupFinished response code: 0
V/BranchSDK(17786): All Install Referrers: [InstallReferrerResult(appStore=PlayStore, latestInstallTimestamp=1736808262, latestRawReferrer=utm_source=google-play&utm_medium=organic, latestClickTimestamp=0, isClickThrough=true), null, null, null, null]
V/BranchSDK(17786): Latest Install Referrer: InstallReferrerResult(appStore=PlayStore, latestInstallTimestamp=1736808262, latestRawReferrer=utm_source=google-play&utm_medium=organic, latestClickTimestamp=0, isClickThrough=true)
V/BranchSDK(17786): fetchInstallReferrer resumeWith got result: InstallReferrerResult(appStore=PlayStore, latestInstallTimestamp=1736808262, latestRawReferrer=utm_source=google-play&utm_medium=organic, latestClickTimestamp=0, isClickThrough=true)
V/BranchSDK(17786): INSTALL_REFERRER_FETCH_WAIT_LOCK removed
V/BranchSDK(17786): processNextQueueItem onInstallReferrersFinished
V/BranchSDK(17786): Queue is: io.branch.referral.ServerRequestRegisterInstall@ec5b417 with locks []
D/BranchSDK(17786): processNextQueueItem, req io.branch.referral.ServerRequestRegisterInstall@ec5b417
V/BranchSDK(17786): executeTimedBranchPostTask io.branch.referral.ServerRequestRegisterInstall@ec5b417
V/BranchSDK(17786): callback to be returned br.com.rsmarques.flutter_branch_sdk.FlutterBranchSdkPlugin$1@1c713cf
V/BranchSDK(17786): onPreExecute io.branch.referral.ServerRequestRegisterInstall@ec5b417
V/BranchSDK(17786): doFinalUpdateOnMainThread
V/BranchSDK(17786): doFinalUpdateOnBackgroundThread
V/BranchSDK(17786): Beginning rest post for io.branch.referral.ServerRequestRegisterInstall@ec5b417
V/BranchSDK(17786): posting to https://api2.branch.io/v1/install
...
D/FlutterBranchSDK(17786): triggered getLatestReferringParams
D/FlutterBranchSDK(17786): triggered onListen
V/BranchSDK(17786): onPostExecuteInner io.branch.referral.ServerRequestQueue$BranchPostTask@935b0bc io.branch.referral.ServerResponse@51db845
V/BranchSDK(17786): onRequestFailed
D/FlutterBranchSDK(17786): triggered onInitFinished
D/FlutterBranchSDK(17786): BranchReferralInitListener - error: Trouble initializing Branch. Task exceeded timeout.
V/BranchSDK(17786): processNextQueueItem onPostExecuteInner
V/BranchSDK(17786): Queue is:

Does anything here would suggest what went wrong?

@gabidev89
Copy link
Author

E/BranchSDK(17786): Branch Networking Error:
E/BranchSDK(17786): URL: https://api2.branch.io/v1/install
E/BranchSDK(17786): Response Code: -1
E/BranchSDK(17786): Response Message:
E/BranchSDK(17786): Caught exception type: java.net.SocketTimeoutException
E/BranchSDK(17786): Retry number: 2
E/BranchSDK(17786): requestId:
E/BranchSDK(17786): Final attempt: false
E/BranchSDK(17786): Object: io.branch.referral.network.BranchRemoteInterfaceUrlConnection@c5aa887
E/BranchSDK(17786): Exception Message: Read timed out
E/BranchSDK(17786): Stacktrace: java.net.SocketTimeoutException: Read timed out
E/BranchSDK(17786): at java.net.SocketInputStream.socketRead0(Native Method)
E/BranchSDK(17786): at java.net.SocketInputStream.socketRead(SocketInputStream.java:118)
E/BranchSDK(17786): at java.net.SocketInputStream.read(SocketInputStream.java:173)
E/BranchSDK(17786): at java.net.SocketInputStream.read(SocketInputStream.java:143)
E/BranchSDK(17786): at com.android.org.conscrypt.ConscryptEngineSocket$SSLInputStream.readFromSocket(ConscryptEngineSocket.java:985)
E/BranchSDK(17786): at com.android.org.conscrypt.ConscryptEngineSocket$SSLInputStream.processDataFromSocket(ConscryptEngineSocket.java:949)
E/BranchSDK(17786): at com.android.org.conscrypt.ConscryptEngineSocket$SSLInputStream.-$$Nest$mprocessDataFromSocket(Unknown Source:0)
E/BranchSDK(17786): at com.android.org.conscrypt.ConscryptEngineSocket.doHandshake(ConscryptEngineSocket.java:238)
E/BranchSDK(17786): at com.android.org.conscrypt.ConscryptEngineSocket.startHandshake(ConscryptEngineSocket.java:220)
E/BranchSDK(17786): at com.android.okhttp.internal.io.RealConnection.connectTls(RealConnection.java:196)
E/BranchSDK(17786): at com.android.okhttp.internal.io.RealConnection.connectSocket(RealConnection.java:153)
E/BranchSDK(17786): at com.android.okhttp.internal.io.RealConnection.connect(RealConnection.java:116)
E/BranchSDK(17786): at com.android.okhttp.internal.http.StreamAllocation.findConnection(StreamAllocation.java:186)
E/BranchSDK(17786): at com.android.okhttp.internal.http.StreamAllocation.findHealthyConnection(StreamAllocation.java:128)
E/BranchSDK(17786): at com.android.okhttp.internal.http.StreamAllocation.newStream(StreamAllocation.java:97)
E/BranchSDK(17786): at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:289)
E/BranchSDK(17786): at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:232)
E/BranchSDK(17786): at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:465)
E/BranchSDK(17786): at com.android.okhttp.internal.huc.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:131)
E/BranchSDK(17786): at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getOutputStream(HttpURLConnectionImpl.java:262)
E/BranchSDK(17786): at com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.getOutputStream(DelegatingHttpsURLConnection.java:219)
E/BranchSDK(17786): at com.android.okhttp.internal.huc.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java:30)
E/BranchSDK(17786): at io.branch.referral.network.BranchRemoteInterfaceUrlConnection.doRestfulPost(BranchRemoteInterfaceUrlConnection.java:201)
E/BranchSDK(17786): at io.branch.referral.network.BranchRemoteInterfaceUrlConnection.doRestfulPost(BranchRemoteInterfaceUrlConnection.java:280)
E/BranchSDK(17786): at io.branch.referral.network.BranchRemoteInterfaceUrlConnection.doRestfulPost(BranchRemoteInterfaceUrlConnection.java:280)
E/BranchSDK(17786): at io.branch.referral.network.BranchRemoteInterfaceUrlConnection.doRestfulPost(BranchRemoteInterfaceUrlConnection.java:67)
E/BranchSDK(17786): at io.branch.referral.network.BranchRemoteInterface.make_restful_post(BranchRemoteInterface.java:137)
E/BranchSDK(17786): at io.branch.referral.ServerRequestQueue$BranchPostTask.doInBackground(ServerRequestQueue.java:525)
E/BranchSDK(17786): at io.branch.referral.ServerRequestQueue$BranchPostTask.doInBackground(ServerRequestQueue.java:495)
E/BranchSDK(17786): at android.os.AsyncTask$3.call(AsyncTask.java:394)
E/BranchSDK(17786): at java.util.concurrent.FutureTask.run(FutureTask.java:264)
E/BranchSDK(17786): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
E/BranchSDK(17786): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
E/BranchSDK(17786): at java.lang.Thread.run(Thread.java:1012)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants