Merge pull request #56 from SamMatthewsIsACommonName/patch-1

Update faqs.md
This commit is contained in:
Elliot Hesp 2017-04-18 08:32:54 +01:00 committed by GitHub
commit eb1b133188
1 changed files with 77 additions and 4 deletions

View File

@ -42,7 +42,17 @@ export function onAuthStateChanged() {
}
```
### [Android] Google Play Services is required to run this application but no valid installation was found
### [Android] Google Play Services related issues
The firebase SDK requires a certain version of Google Play Services installed on Android in order to function properly.
If the version of Google Play Services installed on your device is incorrect or non existent, React Native Firebase will throw a red box error, and your app will possibly crash as well. The red box error will have a numerical code associated with it. These codes can be found here:
https://developers.google.com/android/reference/com/google/android/gms/common/ConnectionResult#SERVICE_VERSION_UPDATE_REQUIRED
Here is a quick guide to some of the most common errors encountered:
code 2 - Google Play Services is required to run this application but no valid installation was found:
The emulator/device you're using does not have the Play Services SDK installed.
@ -50,4 +60,67 @@ The emulator/device you're using does not have the Play Services SDK installed.
create a new emulator image. When selecting your system image, ensure the target comes "with Google APIs".
- Device: Play Services needs to be downloaded from the Google Play Store.
code 9 - The version of the Google Play services installed on this device is not authentic:
This error applies to modified or 'shimmed' versions of Google Play Services which you might be using in a third
party emulator such as GenyMotion.
Using this kind of workaround with Google Play Services can be problematic, so we
recommend using the native Android Studio emulators to reduce the chance of these complications.
### [Android] Turning off Google Play Services availability errors
G.P.S errors can be turned off using a config option like so:
```javascript
const firebase = RNFirebase.initializeApp({
errorOnMissingPlayServices: false,
});
```
This will stop your app from immediately red-boxing or crashing, but won't solve the underlying issue of G.P.S not being available or of the correct version. This will mean certain functionalities won't work properly and your app may even crash.
### [Android] Checking for Google Play Services availability with React Native Firebase
React Native Firebase actually has a useful helper object for checking G.P.S availability:
```javascript
const availability = firebase.googleApiAvailability;
```
The availability object would then have the following properties that you can run checks against:
```javascript
isAvailable: boolean
```
and if not available (isAvailable === false):
```javascript
isUserResolvableError: boolean
```
This variable indicates whether or not the end user can fix the issue, for example by downloading the required version of Google Play Services. In a case such as a GenyMotion emulator, this would return false for missing G.P.S, as the end user can't add the package directly.
```javascript
error: string
```
This error will match the messages and error codes mentioned above, and can be found here:
https://developers.google.com/android/reference/com/google/android/gms/common/ConnectionResult#SERVICE_VERSION_UPDATE_REQUIRED
### [Android] Duplicate Dex Files error (build time error)
A common build time error when using libraries that require google play services is of the form:
'Failed on android with com.android.dex.DexException: Multiple dex files... '
This error (https://github.com/invertase/react-native-firebase/issues/48) occurs because different versions of google play services or google play services modules are being required by different libraries.
The process to fix this is fairly manual and depends on your specific combination of external libraries. Essentially what's required is to check the app level build.gradle file of each external library and establish which ones have a Google Play Services dependency.
You then need to find the lowest common version of each G.P.S module dependency, require that in the app level build.gradle file of your own project, and exclude it from being required by the modules themselves. This will force the use of a consistent version of the G.P.S module.
It's not a good idea to modify the version within the library's build.gradle, as this will be overwritten when you update the library, which will lead to the build breaking again.
A good break down of this process can be found here:
https://medium.com/@suchydan/how-to-solve-google-play-services-version-collision-in-gradle-dependencies-ef086ae5c75f