I am integrating Instabug into an Application, and Instabug needs to be initialized in the Application class. But, The Environment(Live or Beta) the user is logging in will only be known once the user logs in. And Instabug integration requires you to provide the API token for the particular Environment. Since we don't know which environment the user is logging in, I can't instantiate Instabug in Application
class. Is there a workaround?

- 37,901
- 21
- 84
- 115

- 9
- 3
-
If you make a manifest entry for application class of the `Application` will be instantiate automatically . So workaround is check inside application class before initializing Instabug. – ADM Jul 03 '18 at 14:54
1 Answers
let's break it down into two issues
1- "Instabug needs to be initialized in the Application class. But, The Environment(Live or Beta) the user is logging in will only be known once the user logs in."
As per my understanding, you only need to disable and enable Instabug at runtime.
Which is easily doable by initializing Instabug in the application class normally and you can disable it right after the initialization using this API Instabug.disable();
In case you want to enable Instabug later, you can do that by calling Instabug.enable();
at runtime.
(in your case right after users sign up).
2- regarding the beta or live, you can ship your APK with Instabug initialized using the beta-token and whenever you want to release a live APK you can use the live-token and ship your release to Google Play.

- 665
- 1
- 8
- 22
-
-
I am aware of this solution, but this doesn't work for our app. I need to initialize it after the login with the live or beta token. – Harsh Saini Aug 02 '18 at 04:36