@@ -142,17 +142,17 @@ public Thread newThread(Runnable r) {
142142 * FirebaseOptions#getApplicationId()} , and ({@link FirebaseOptions#getProjectId()} are not null
143143 * or empty.
144144 */
145- private void preConditionChecks () {
146- Preconditions .checkNotEmpty (getApplicationId ());
147- Preconditions .checkNotEmpty (getProjectIdentifier ());
148- Preconditions .checkNotEmpty (getApiKey ());
145+ private static void preConditionChecks (@ NonNull FirebaseApp app ) {
146+ Preconditions .checkNotEmpty (app . getOptions (). getApplicationId ());
147+ Preconditions .checkNotEmpty (app . getOptions (). getProjectId ());
148+ Preconditions .checkNotEmpty (app . getOptions (). getApiKey ());
149149 Preconditions .checkArgument (
150- Utils .isValidAppIdFormat (getApplicationId ()),
150+ Utils .isValidAppIdFormat (app . getOptions (). getApplicationId ()),
151151 "Please set your Application ID. A valid Firebase App ID is required to communicate "
152152 + "with Firebase server APIs: It identifies your application with Firebase."
153153 + "Please refer to https://firebase.google.com/support/privacy/init-options." );
154154 Preconditions .checkArgument (
155- Utils .isValidApiKeyFormat (getApiKey ()),
155+ Utils .isValidApiKeyFormat (app . getOptions (). getApiKey ()),
156156 "Please set a valid API key. A Firebase API key is required to communicate with "
157157 + "Firebase server APIs: It authenticates your project with Google."
158158 + "Please refer to https://firebase.google.com/support/privacy/init-options." );
@@ -184,6 +184,7 @@ public static FirebaseInstallations getInstance() {
184184 @ NonNull
185185 public static FirebaseInstallations getInstance (@ NonNull FirebaseApp app ) {
186186 Preconditions .checkArgument (app != null , "Null is not a valid value of FirebaseApp." );
187+ preConditionChecks (app );
187188 return (FirebaseInstallations ) app .get (FirebaseInstallationsApi .class );
188189 }
189190
@@ -212,7 +213,6 @@ String getName() {
212213 @ NonNull
213214 @ Override
214215 public Task <String > getId () {
215- preConditionChecks ();
216216 Task <String > task = addGetIdListener ();
217217 backgroundExecutor .execute (this ::doGetId );
218218 return task ;
@@ -229,7 +229,6 @@ public Task<String> getId() {
229229 @ NonNull
230230 @ Override
231231 public Task <InstallationTokenResult > getToken (boolean forceRefresh ) {
232- preConditionChecks ();
233232 Task <InstallationTokenResult > task = addGetAuthTokenListener ();
234233 if (forceRefresh ) {
235234 backgroundExecutor .execute (this ::doGetAuthTokenForceRefresh );
0 commit comments