The Crashlytics for Firebase Unity Sample demonstrates the Firebase SDK for Crashlytics with the Firebase Unity SDK inside the Unity Editor.
- Unity The quickstart project requires 2017.4 or higher.
- Xcode 10.3 or higher (when developing for iOS).
- Android SDK (when developing for Android).
- Download the Firebase Unity SDK and unzip it somewhere convenient.
- Open this sample project in the Unity editor.
- Select
File > Open Project
menu item. - If Unity Hub appears, click
Add
. Otherwise clickOpen
. - Navigate to this sample project directory
testapp
in the file dialog and clickOpen
.- You might be prompted to upgrade the project to your version of Unity.
Click
Confirm
to upgrade the project and continue.
- You might be prompted to upgrade the project to your version of Unity.
Click
- Select
- Open the scene
MainScene
.- Navigate to
Assets/Firebase/Sample/Crashlytics
in theProject
window. - Double click on the
MainScene
file to open it.
- Navigate to
- Import the
Firebase Crashlytics
plugin.- Select the Assets > Import Package > Custom Package menu item.
- From the Firebase Unity SDK
downloaded previously, import
FirebaseCrashlytics.unitypackage
. - When the Import Unity Package window appears, click the Import button.
Once you have done this, you can run the Unity Editor and test the application.
- Create a new Firebase project and Unity iOS app.
- You should use
com.google.firebase.unity.crashlytics.testapp
as the iOS bundle ID when creating the Firebase iOS app in the console.- If you do not use the prescribed Bundle ID, you will later need to
update the bundle identifier in Unity as described in the
Optional: Update the Project Bundle Identifier
below.
- If you do not use the prescribed Bundle ID, you will later need to
update the bundle identifier in Unity as described in the
- Download the
GoogleService-Info.plist
file associated with your Firebase project from the console.- For further details please refer to the general instructions which describes how to configure a Firebase application for iOS.
- You should use
- Add the
GoogleService-Info.plist
file to the project.- Navigate to the
Assets/Firebase/Sample/Crashlytics
folder in theProject
window. - Drag the
GoogleService-Info.plist
downloaded from the Firebase console into the folder.- NOTE:
GoogleService-Info.plist
can be placed anywhere under theAssets
folder.
- NOTE:
- Navigate to the
- Set up Crashlytics
- In the Firebase console -> Select your project -> Select Crashlytics -> Setup Crashlytics -> Select that the app is new. (You do not need to download the SDK again as you have already downloaded the Unity plugin)
- Optional: Update the Project Bundle Identifier
- If you did not use
com.google.firebase.unity.crashlytics.testapp
as the iOS bundle ID when creating your app in the Firebase Console, you will need to update the sample's Bundle Identifier.- Select the
File > Build Settings
menu option. - Select
iOS
in thePlatform
list. - Click
Player Settings
. - In the
Settings for iOS
panel scroll down toBundle Identifier
and update the value to theiOS bundle ID
you provided when you registered your app with Firebase.
- Select the
- If you did not use
- Build for iOS
- Select the
File > Build Settings
menu option. - Select
iOS
in thePlatform
list. - Click
Switch Platform
to selectiOS
as the target platform. - Wait for the spinner (compiling) icon to stop in the bottom right corner of the Unity status bar.
- Click
Build and Run
.
- Select the
- Create a new Firebase project and Unity Android app.
- You should use
com.google.firebase.unity.crashlytics.testapp
as theAndroid package name
while you're testing.- If you do not use the prescribed package name, you will need to update
the bundle identifier as described in
Optional: Update the Project Bundle Identifier
below.
- If you do not use the prescribed package name, you will need to update
the bundle identifier as described in
- Android apps must be signed by a key, and the key's signature must
be registered to your project in the Firebase Console. To
generate a SHA1,
first you will need to set the keystore in the Unity project.
- Locate the
Publishing Settings
underPlayer Settings
. - Select an existing keystore, or create a new keystore using the toggle.
- Select an existing key, or create a new key using "Create a new key".
- After setting the keystore and key, you can generate a SHA1 by
running this command:
keytool -list -v -keystore <path_to_keystore> -alias <key_name>
- Copy the SHA1 digest string into your clipboard.
- Navigate to your Android App in your firebase console.
- From the main console view, click on your Android App at the top and click the gear to open the settings page.
- Scroll down to your apps at the bottom of the page and click on
Add Fingerprint
.
- Paste the SHA1 digest of your key into the form. The SHA1 box will illuminate if the string is valid. If it's not valid, check that you have copied the entire SHA1 digest string.
- Locate the
- Download the
google-services.json
file associated with your Firebase project from the console.- For further details please refer to the general instructions which describes how to configure a Firebase application for Android.
- You should use
- Add the
google-services.json
file to the project.- Navigate to the
Assets/Firebase/Sample/Crashlytics
folder in theProject
window. - Drag the
google-services.json
downloaded from the Firebase console into the folder.- NOTE:
google-services.json
can be placed anywhere under theAssets
folder.
- NOTE:
- Navigate to the
- Set up Crashlytics
- In the Firebase console -> Select your project -> Select Crashlytics -> Setup Crashlytics -> Select that the app is new. (You do not need to download the SDK again as you have already downloaded the Unity plugin)
- Optional: Update the Project Bundle Identifier
- If you did not use
com.google.firebase.unity.crashlytics.testapp
as theAndroid package name
when you created your app in the Firebase Console, you will need to update the sample's Bundle Identifier.- Select the
File > Build Settings
menu option. - Select
Android
in thePlatform
list. - Click
Player Settings
- In the
Settings for Android
panel scroll down toBundle Identifier
and update the value to the Android package name you provided when you registered your app with Firebase.
- Select the
- If you did not use
- Build for Android
- Select the
File > Build Settings
menu option. - Select
Android
in thePlatform
list. - Click
Switch Platform
to selectAndroid
as the target platform. - Wait for the spinner (compiling) icon to stop in the bottom right corner of the Unity status bar.
- Click
Build and Run
.
- Select the
- Once the Unity test app is running (detach debugger if attached), click the
Perform All Actions
button. - Trigger upload by completely closing and relaunching the test app.
- To view the reported issues, go to the
Firebase Crashlytics console for the
test app.
- Add a time filter to more easily identify the errors if needed
- When upgrading to a new Firebase release: import the new firebase unity package through Assets > Import Package > Custom Package as above. After the import is complete you may need to run the Assets > Play Services Resolver for the changes to be reflected in the editor. If issues persist, delete the plugin and install it again.
- Android: After exiting the editor and returning you will need to reconfigure the Project Keystore in Player Settings > Publishing Settings. Select your Custom Keystore from the dropdown list and enter its password. Then, select your Project Key alias and enter your key's password. enabled in your project, you'll see compile errors from some types in the
- Please see the Known Issues section of the Unity Setup Guide](https://firebase.google.com/docs/unity/setup) for other troubleshooting topics.
https://firebase.google.com/support/
Copyright 2018 Google, Inc.
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.