yandexmobile / metrica-sdk-android

AppMetrica is a free real-time ad tracking and mobile app analytics solution.
https://tech.yandex.com/metrica-mobile-sdk/
19 stars 3 forks source link

Application.onCreate called twice #63

Closed protreptic closed 6 years ago

protreptic commented 6 years ago

I ecountered with suspitios SDK behavior. It seems that Application.onCreate called twice during app lifecycle. Not 100% sure. But some how after I added:

    @Override
    public void onCreate() {
        super.onCreate();

        if (!CURRENT_ROCESS_NAME.equals(getCurrentProcessName()))
            return;
    }

problem disappeared.

Is it a real problem or just my misunderstanding? How do you think, can these code broke SDK functionality or not?

Thanks in advance!

alexklints commented 6 years ago

It's valid behavior. Please read "How the AppMetrica library works" from documentation. If you use

if (!CURRENT_ROCESS_NAME.equals(getCurrentProcessName()))
            return;

AppMetrica will not be activated for it's own process. So, you will not receive any errors from AppMetrica's process.

kirkaDev commented 1 year ago

It's valid behavior. Please read "How the AppMetrica library works" from documentation. If you use

if (!CURRENT_ROCESS_NAME.equals(getCurrentProcessName()))
            return;

AppMetrica will not be activated for it's own process. So, you will not receive any errors from AppMetrica's process.

Here is a actual (alive) link and quote from here translated to EN: "Don't add code to the Application.onCreate() method that shouldn't run more than once. Run such code when creating other components or move it to a separate Service."

@alexklints , thank you for your clarification, I also faced with this problem and had unexpected twice logs.