<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: A. Izzuddiin A.</title>
    <description>The latest articles on DEV Community by A. Izzuddiin A. (@dinjudin).</description>
    <link>https://dev.to/dinjudin</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F478400%2F9bc42518-304c-4acc-8a84-d42137ae8766.jpg</url>
      <title>DEV Community: A. Izzuddiin A.</title>
      <link>https://dev.to/dinjudin</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/dinjudin"/>
    <language>en</language>
    <item>
      <title>Easy Way to Beautify Your Ugly React Native Stack Trace</title>
      <dc:creator>A. Izzuddiin A.</dc:creator>
      <pubDate>Mon, 05 Oct 2020 01:57:16 +0000</pubDate>
      <link>https://dev.to/dinjudin/easy-way-to-beautify-your-ugly-react-native-stack-trace-kfn</link>
      <guid>https://dev.to/dinjudin/easy-way-to-beautify-your-ugly-react-native-stack-trace-kfn</guid>
      <description>&lt;p&gt;&lt;em&gt;Cover Photo by &lt;a href="https://unsplash.com/@martijnbaudoin?utm_source=devto&amp;amp;utm_medium=referral" rel="noopener noreferrer"&gt;Martijn Baudoin&lt;/a&gt; on &lt;a href="https://unsplash.com/?utm_source=devto&amp;amp;utm_medium=referral" rel="noopener noreferrer"&gt;Unsplash&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;




&lt;p&gt;Have you ever had trouble reading your react native app's stack trace on the Firebase Crashlytics Console? So do I. It was very difficult (close to impossible) to understand the crash stack trace generated from the obfuscated code.&lt;/p&gt;

&lt;p&gt;This ugly stack trace comes from a crash that occurred on javascript/react native side. This happened because Crashlytics cannot automatically de-obfuscate JSC/V8's (&lt;a href="https://reactnative.dev/docs/javascript-environment" rel="noopener noreferrer"&gt;JS engines that used by react native&lt;/a&gt;) stack trace.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F5cdesqxtnyn6epkswe7s.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F5cdesqxtnyn6epkswe7s.png" alt="Pic 1: Stack trace displayed on Firebase Crashlytics Console"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The problem above does not happen if the crash occurred on the native side (Android or IOS). Crashlytics can automatically get a mapping file on Android, and debug symbol (dSYM) file on iOS and &lt;a href="https://firebase.google.com/docs/crashlytics/get-deobfuscated-reports" rel="noopener noreferrer"&gt;upload it to Crashlytics Server&lt;/a&gt;. Those two files are the key so Crashlytics can de-obfuscate an ugly stack trace.&lt;/p&gt;




&lt;h2&gt;
  
  
  Stack Trace Beautifier
&lt;/h2&gt;

&lt;p&gt;But, don't worry. &lt;a href="https://github.com/software-mansion-labs/stack-beautifier" rel="noopener noreferrer"&gt;stack-beautifier&lt;/a&gt; come to the rescue. stack-beautifier is a tool that can help you to de-obfuscate an ugly stack trace. We don't have to integrate anything into your app. We just need to install this library to our machine and provide a source map file and stack trace file. Then, let stack beautifier do the rest.&lt;/p&gt;

&lt;p&gt;Here the steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Install this library to your machine. Run &lt;code&gt;npm install -g stack-beautifier&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Open Firebase Crashlytics Console and find crashes titled &lt;code&gt;ExceptionsManagerModule.java ...&lt;/code&gt;. These are crashes that occurred on javascript/react native side.&lt;/li&gt;
&lt;li&gt;Create an empty text file and copy-paste stack trace from Firebase Crashlytics Console into it. Look at Pic 1 to determine where is the stack trace do you need.&lt;/li&gt;
&lt;li&gt;Run &lt;code&gt;stack-beautifier [path to. your source map] -t [path to your stack trace files]&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Voila, you have beautified ugly stack-trace.
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F72abg9194pj8qcdp9b0u.png" alt="Pic 2: De-obfuscated Stack Trace"&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Obstacles
&lt;/h2&gt;

&lt;p&gt;You will find some obstacles when you followed those steps.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;You Don't Have Source Map / Source Map is Missing&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You just need to re-generated it. Add this variable to your &lt;code&gt;app/build.gradle&lt;/code&gt; file:&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;project.ext.react = [&lt;br&gt;
      extraPackagerArgs: ['--sourcemap-output', &lt;br&gt;
      file("$buildDir/outputs/index.android.js.map")]&lt;br&gt;
 ]&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;Then, rebuild your app using release mode. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Important&lt;br&gt;
You need to rebuild it on a codebase that exactly as same as the app that you have uploaded to Playstore.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;You Found &lt;code&gt;Stack trace parse error at line xx&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;
This happened because your stack trace contains an unrecognized format by stack-beautifier. You need to change your stack trace as same as the documentation said: &lt;a href="https://github.com/software-mansion-labs/stack-beautifier#stack-trace-input-format" rel="noopener noreferrer"&gt;Stack trace input format&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;




&lt;p&gt;You can reach me on &lt;a href="//mailto:abdullahizzuddiin@gmail.com"&gt;Email&lt;/a&gt; and &lt;a href="https://twitter.com/dinjudin" rel="noopener noreferrer"&gt;Twitter&lt;/a&gt;. Let's talk :D&lt;/p&gt;

</description>
      <category>reactnative</category>
      <category>javascript</category>
      <category>stacktrace</category>
      <category>android</category>
    </item>
  </channel>
</rss>
