Skip to content

Commit d317bb7

Browse files
markchandlera-maurice
authored andcommitted
Fixed assert on android when not using default app instance and trying to auth.
Github issue: firebase/quickstart-unity#461 PiperOrigin-RevId: 268992783
1 parent 41f3d88 commit d317bb7

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

app/src/app_common.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,10 @@ App* FindAppByName(const char* name) {
301301
App* GetDefaultApp() { return g_default_app; }
302302

303303
App* GetAnyApp() {
304+
if (g_default_app) {
305+
return g_default_app;
306+
}
307+
304308
MutexLock lock(g_app_mutex);
305309
if (g_apps && !g_apps->empty()) {
306310
return g_apps->begin()->second->app;

auth/src/android/credential_android.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <cstring>
2121

2222
#include "app/src/assert.h"
23+
#include "app/src/app_common.h"
2324
#include "app/src/build_type_generated.h"
2425
#include "app/src/embedded_file.h"
2526
#include "app/src/include/firebase/app.h"
@@ -310,9 +311,8 @@ void ReleaseCredentialClasses(JNIEnv* env) {
310311
}
311312

312313
static JNIEnv* GetJniEnv() {
313-
// The default App must always exist, and the JNI environment is the same
314-
// regardless of App.
315-
App* app = App::GetInstance();
314+
// The JNI environment is the same regardless of App.
315+
App* app = app_common::GetAnyApp();
316316
FIREBASE_ASSERT(app != nullptr);
317317
return app->GetJNIEnv();
318318
}

0 commit comments

Comments
 (0)