Error getting advertiser id
Asked Answered
P

4

12

I noticed that my google analytics ecommerce data are not properly delivered by my android app, while all the other analytics data (screen views, exceptions) are correctly published.

I already opened a bounty about this topic but digging further I discovered some errors in the logcat:

Error getting advertiser id: java.io.IOException: java.util.concurrent.TimeoutException: Timed out waiting for the service connection

Successfully bound to service but never got onServiceConnected callback

I suspect these errors are due to something not working at play-services level, that's why I'm opening a new thread.

Since the above errors appear in logs before hits are delivered my theory is that my ecommerce data are not correctly posted because of them. Did anybody here ever see anything like that? What could I try in order to fix it?

Please notice I'm using (taken from build.gradle)

compile 'com.google.android.gms:play-services-analytics:9.4.0'
compile 'com.google.android.gms:play-services-ads:9.4.0'

apply plugin: 'com.google.gms.google-services'

and the gradle plugin

classpath 'com.android.tools.build:gradle:2.2.0-beta1'
Prig answered 11/8, 2016 at 9:40 Comment(4)
Hi Marco. I have some problem with GMS 9.4.0 and not found solution...My app freeze on start after this log message: Error getting advertiser id: java.io.IOException: java.util.concurrent.TimeoutException: Timed out waiting for the service connection Successfully bound to service but never got onServiceConnected callbackScrutable
well, my app doesn't freeze but still can't deliver ecommerce data to analytics...Prig
I found a releated report here: groups.google.com/forum/#!topic/google-admob-ads-sdk/… looks like the problem is still there in gms 9.8Akim
Hi guys, any updates on this? I experience this with tag manager 11.8.0. And I don't see any solution at all.Overtop
W
1

I fixed this error by adding this to dependencies block in gradle.build file:

implementation 'com.google.android.gms:play-services-base:16.0.1'
Whenas answered 9/1, 2019 at 22:50 Comment(0)
S
0

In my case another error (A Virtual method not found error) was holding this and causing this to timeout. After resolving it, Ad id was successfully retrieved.

Schlesien answered 16/1, 2020 at 7:48 Comment(0)
P
0

I had the following error

java.util.concurrent.TimeoutException: Timed out waiting for the service connection

The error has been fixed after the caller method was moved to the non-main thread. I'm not sure this solution will help you but you can check it out.

Petunia answered 21/9, 2020 at 11:15 Comment(1)
I get this exception but I'm calling from a suspend function and using withContext(Dispatchers.IO) to call getAdvertisingIdInfo(). I've verified and it is not on the main thread.Marin
D
0

From my latest tests it seems that onServiceConnected is not called when trying to get an android id from the main thread. It can lead to deadlocks (as in @DimPar case) and to timeout exceptions, when you try to prevent a deadlock with a timeout on a Thread.join. It seems that android doesn't allow external SDK to create separate threads (even when they directly do that by creating a new Thread and starting it). In other words - if you use an sdk that tries to get the android id even if it should work - it won't. The solution to this would call all the external SDK functions on separate thread that you create in the activity. Here is an example from my personal experience.
The following code block deadlocks:

public class MainActivity extends AppCompatActivity {
    static boolean doOnce = true;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        if( doOnce ) {
            ExternalSDKClass.StartInitialization();
            doOnce = false;
        }
}

The following code block works

public class MainActivity extends AppCompatActivity {

    Thread ExternalSDKThread = new Thread() {
        @Override
        public void run() {
            try {
                ExternalSDKClass.StartInitialization();
            } catch (Exception e) {
                Log.i("SDK ERROR", "getAdvertisingIdInfo Exception: " + e.toString());
            }
        }
    };
    //---------------------------------

    static boolean doOnce = true;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        if( doOnce ) {
            ExternalSDKThread.start();
            doOnce = false;
        }
}
Duello answered 8/2, 2021 at 8:34 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.