Skip to content

Commit 06eebad

Browse files
authored
fix(app, android): fixes possible crash on first launch (#4990)
Fixes #4979
1 parent 038063e commit 06eebad

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

packages/app/android/src/reactnative/java/io/invertase/firebase/utils/ReactNativeFirebaseUtilsModule.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,11 @@ public Map<String, Object> getConstants() {
159159
constants.put(KEY_TEMP_DIRECTORY, context.getCacheDir().getAbsolutePath());
160160
constants.put(KEY_CACHE_DIRECTORY, context.getCacheDir().getAbsolutePath());
161161

162-
162+
File externalDirectory = context.getExternalFilesDir(null);
163163
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
164-
constants.put(KEY_DOCUMENT_DIRECTORY, context.getExternalFilesDir(null).getAbsolutePath());
164+
if ( externalDirectory != null ) {
165+
constants.put(KEY_DOCUMENT_DIRECTORY, externalDirectory.getAbsolutePath());
166+
}
165167
} else {
166168
constants.put(KEY_DOCUMENT_DIRECTORY, context.getFilesDir().getAbsolutePath());
167169
}
@@ -179,7 +181,6 @@ public Map<String, Object> getConstants() {
179181
constants.put(KEY_EXT_STORAGE_DIRECTORY, externalStorageDirectory.getAbsolutePath());
180182
}
181183

182-
File externalDirectory = context.getExternalFilesDir(null);
183184
if (externalDirectory != null) {
184185
constants.put(KEY_EXTERNAL_DIRECTORY, externalDirectory.getAbsolutePath());
185186
}

0 commit comments

Comments
 (0)