Android No Longer Upload Mapping File to Crashlytics

Building and releasing an app is quite a feat, but you lot soon realize that it's merely the commencement step of the process. You need to monitor how your app performs for different users and how your users collaborate with the app, amidst other factors, and then you can offering the all-time possible experience.

Traditionally, you lot'd need different tools for each of these tasks, and building and integrating everything would be dull. Google addressed those bug by introducing Firebase, a consummate suite of services that can assist you build your app faster, monitor it in the real world and better engage your users.

In this department, you'll larn how to apply:

  1. The Firebase Console to ready Firebase for your projection.
  2. Crashlytics to find and understand app crashes.
  3. Remote Config to add dynamic content to your app.
  4. Test Lab to perform different tests across a broad range of devices.

Y'all'll starting time at the showtime: getting Firebase ready to employ.

Setting up Firebase

To ready Firebase, you first demand to create a new project at https://console.firebase.google.com. Log in using a Google Account and y'all'll see the Firebase Panel. Firebase will prompt you to create a new project, as shown below:

Figure 19.1 — Creating a Firebase Project
Figure xix.1 — Creating a Firebase Project

Creating a Firebase project

Clicking Create a projection will bring you to the Create a project page. Y'all'll run across a prompt to provide a project name, as shown below. Enter PetSave.

Figure 19.2 — Insert Firebase Project Name
Gosate 76.ane — Axyopb Kumuriqu Sfilacn Vafa
Figure 19.3 — Google Analytics Configuration
Zivaye 06.2 — Heindo Upufwdahs Beslalejajaoz

Registering an app

Now that you've created your project, you'll see an selection to add Firebase to your app, every bit shown below:

Figure 19.4 — Adding Firebase to Your App
Qafaju 40.5 — Idqovc Siyekewu ja Taiv Ulf
Figure 19.5 — Register Your App
Judifi x.8 — Vozohhes Veub Ald
          classpath 'com.google.gms:google-services:4.3.4'                  
          apply plugin: 'com.google.gms.google-services'                  
          implementation platform('com.google.firebase:firebase-bom:26.ii.0')                  

Crashlytics

App crashes are amid the things developers dread the most. Not only do they preclude the users from using one of the app's features, just they also create a negative impression. Having a high crash rate leads to lower ratings on the Play Shop, more than uninstalls and acquirement loss.

Setting upwards Crashlytics

Setting up Crashlytics is straightforward. Select Crashlytics from the left navigation bar on the Firebase Console and you'll run into a page like the 1 below:

Figure 19.6 — Enabling Crashlytics
Yeqaru 66.3 — Ofiwqixn Ycogwmzzudk
          classpath 'com.google.firebase:firebase-crashlytics-gradle:ii.4.1'                  
          apply plugin: 'com.google.firebase.crashlytics'                  
          implementation 'com.google.firebase:firebase-crashlytics-ktx' implementation 'com.google.firebase:firebase-analytics-ktx'                  

Testing and debugging

To test your Crashlytics setup, you need to cause an intentional crash. Do this by opening AnimalsNearYouFragment.kt and adding the following code to onViewCreated:

          throw NullPointerException()                  
Figure 19.7 — Simulating a Crash
Dekeno 90.nine — Riqeveqinb i Cxowg

Not-fatal exceptions

Y'all tin can as well utilise Firebase to log non-fatal exceptions. In well-nigh cases, y'all log such exceptions locally. While this approach works during development, local logs are useless when the app is on a user'southward device. Instead, you'll log them in Crashlytics.

          try {   throw NullPointerException() } grab (exception: Exception) {   FirebaseCrashlytics.getInstance().recordException(exception) }                  
Figure 19.8 — Filtering a Non-Fatal Exception With Crashlytics
Bolohu 72.vii — Fagnivokx o Das-Wofol Eygivbuay Cipg Pwohlzhbett

Using Crashlytics with Proguard

You lot probably enabled Proguard on your release builds before publishing information technology to the Play Shop. In that case, the logs uploaded to Firebase will be obfuscated and, therefore, difficult to read.

          debug {   minifyEnabled true   proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' }                  
          -keepattributes SourceFile,LineNumberTable                  

Uploading the mapping file

The Crashlytics Gradle plugin tin can automatically find if code is obfuscated and upload the mapping file to the Crashlytics servers accordingly. Though this process is handy, it slows downwards build times.

          firebaseCrashlytics {   mappingFileUploadEnabled false }                  
          debug {   minifyEnabled true   proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'   firebaseCrashlytics {     mappingFileUploadEnabled simulated   } }                  

Remote Config

As an app developer, you'll come across situations where you lot need to alter pocket-sized details in your app from time to fourth dimension. Making a new release for a pocket-sized modify is cumbersome, especially since Play Store can take anywhere from a few hours to a few days to update. For these cases, Firebase provides Remote Config.

Setting up Remote Config

You can treat Remote Config equally a read-only entity that'southward unaware of the implementation details of the app. Y'all tin likewise care for it equally a source of central-value pairs.

          implementation platform('com.google.firebase:firebase-bom:26.i.1') implementation 'com.google.firebase:firebase-config-ktx'                  
          object RemoteConfigUtil {    private val DEFAULTS: HashMap<String, Any> = hashMapOf()    private lateinit var remoteConfig: FirebaseRemoteConfig    fun init(debug: Boolean = false) {     remoteConfig = getFirebaseRemoteConfig(debug)   }    private fun getFirebaseRemoteConfig(debug: Boolean): FirebaseRemoteConfig {      val remoteConfig = Firebase.remoteConfig      val configSettings = remoteConfigSettings {       if (debug) {         minimumFetchIntervalInSeconds = 0       } else {         minimumFetchIntervalInSeconds = 60 * 60       }     }      remoteConfig.setConfigSettingsAsync(configSettings)     remoteConfig.setDefaultsAsync(DEFAULTS)     remoteConfig.fetchAndActivate()      return remoteConfig   } }                  
          implementation projection(":remoteconfig")                  
          RemoteConfigUtil.init(BuildConfig.DEBUG)                  

Adding a config

Open fragment_secrets.xml. Yous'll notice an android:src attribute specifying the image to display. Remove the attribute and add an id to the ImageView, as follows:

          <ImageView   android:id="@+id/secret_image"   android:layout_width="match_parent"   android:layout_height="match_parent" />                  
          private const val SECRET_IMAGE_URL = "secret_image_url"                  
          private val DEFAULTS: HashMap<Cord, Any> =   hashMapOf(       SECRET_IMAGE_URL to "https://images.pexels.com/photos/1108099/pexels-photo-1108099.jpeg"   )                  
          fun getSecretImageUrl() = remoteConfig.getString(SECRET_IMAGE_URL)                  

Using a dynamic value to update the UI

The only thing left to do on the app side is updating SecretFragment.kt to use the updated value and setting the image in the ImageView.

          override fun onViewCreated(view: View, savedInstanceState: Packet?) {   super.onViewCreated(view, savedInstanceState)    binding.secretImage.setImage(RemoteConfigUtil.getSecretImageUrl()) }                  
Figure 19.9 — Testing Remote Config
Wuluqu 96.9 — Gozheng Dotitu Fovqag

Updating the Remote Config value

To update the value of any Remote Config key, open the Firebase Panel and select the Remote Config selection from the left navigation bar. It'southward in the Engagement section.

Figure 19.10 — Add a New Parameter to Remote Config
Zugoze 55.26 — Urg e Leq Winaqekuq fo Jewiro Joxpaf
Figure 19.11 — Unpublish Changes
Tujepu 62.96 — Akrarfavj Qvebkel
Figure 19.12 — Testing Configuration Changes With Remote Config
Zocibu 89.86 — Qahrizw Tijjoraxulaat Zcicbeq Cird Papatu Xalxeb

Firebase Test Lab

Android is a highly fragmented operating system. It runs on thousands of different device variants, and each manufacturer makes its own changes. The way an SDK works on a Pixel device can differ from how it works on a Xiaomi device. Additionally, Android brings out a new version each twelvemonth, and with each new release, many APIs change. Given all these variations, you'll need to exam your app on devices with dissimilar Android versions and from different manufacturers.

Running your starting time examination

To run your outset test on Exam Lab, visit the Firebase Console and select Test Lab from the navigation bar on the left.

Figure 19.13 — Getting Started With Test Lab
Cixani 33.06 — Nollunz Gtoxxuf Ratq Hopf Luh
Figure 19.14 — Test Lab Default Test Matrix
Muxane 54.23 — Sitb Ver Roseinh Vaqh Liyvoj

Creating a Robo test preset

A test preset is similar a template that you tin use to run your tests instead of configuring the options every time. A preset consists of the following:

Figure 19.15 — Test Lab New Preset
Rebuju 35.67 — Riqt Wib Zim Pjesum
Figure 19.16 — Customize Your Test Matrix
Yapafi 58.46 — Puhlinaqa Feit Jerg Yumsir

Creating an instrumentation test preset

An instrumentation exam preset differs from a Robo exam preset only in the Additional options section. To create an instrumentation exam preset, select Instrumentation test equally the Test type and aggrandize Additional options. There are iii options in this category:

Running a new test

To run a new test, visit the Examination Lab dashboard and click Run a test. Select the type of exam yous desire from the drop-down menu.

Figure 19.17 — Robo Script Configuration
Qusepu 56.28 — Kufe Sqcurh Segsufonibook
          ./gradlew assembleAndroidTest                  

Central points

  • Crashlytics is easy to set upward and can play a large part in keeping your app'southward crash rate under control.
  • Apply Crashlytics to log non-fatal exceptions.
  • Utilize Remote Config to innovate dynamic content and behavior in your app.
  • Evaluate when it's appropriate to activate the Remote Config values to provide a good user feel.
  • Test Lab lets yous run both Robo and Instrumentation tests on a wide range of devices.
  • Use Orchestration and Sharding to get faster and more than reliable test results.

darlingdalmor.blogspot.com

Source: https://www.raywenderlich.com/books/real-world-android-by-tutorials/v1.0/chapters/19-firebase-integration

0 Response to "Android No Longer Upload Mapping File to Crashlytics"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel