DEV Community

Cover image for Building software for cattle farmers. Part 2. Production errors
Tristan Elliott
Tristan Elliott

Posted on • Updated on

Building software for cattle farmers. Part 2. Production errors

Introduction

  • In this series I take you along, week by week as I release my app and update you on all of the challenges I have faced from the previous week.
  • The app I have built is an app that allows cattle farmers to track their calves during calving season

My app on the Google play store

HERE

GitHub code

Table of contents

  1. Production errors
  2. Fixing the errors
  3. New features
  4. This weeks goals

Production Errors

  • Immediately after I published my app it would crash on opening, which was really weird since it worked perfectly on my own test device.
  • To try and fix this problem fast I knew I needed some sort of logging and that is when I discovered Timber and Firebase Crashlynics. I then used THIS video to set both of them up and to create a decent crash reporting system.

  • After coming across THIS Stackoverflow question, I realized the crash was caused by a obfuscation error initiated by proguard. By default, proguard runs in production mode but not in debug mode( the reason my app only worked on my test device).

  • If you are unfamiliar with obfuscation, it shortens the name of classes and the members, which results in reduced DEX file sizes. This is fine but it becomes a problem when working with Firebase database models. Before obfuscation my code would look like this:

data class FireBaseCalf(var calftag: String? = null,
                        var cowtag:String? = null,
                        var ccianumber: String? = null,
                        var sex:String? = null,
                        var details:String?=null,
                        var date: Date? = null,
                        var birthweight:String? = null,
                        var id: String? = null,

                        )

Enter fullscreen mode Exit fullscreen mode
  • But after obfuscation my code would look like this:
data class FireBaseCalf(var a: String? = null,
                        var b? = null,
                        var c: String? = null,
                        var d? = null,
                        var e?=null,
                        var f: Date? = null,
                        var g? = null,
                        var h: String? = null,

                        )

Enter fullscreen mode Exit fullscreen mode
  • Which was causing the crash when my app would fetch data

How to fix obfuscation errors?

  • As it turns out, if we read the documentation, HERE, firebase states that this sort of error will happen if the toObject() method is used. THIS is how I fixed the problem

New Features

  • Some of my users ( my dad) requested the feature of being able to choose the birth date of a calf. To implement this feature I used the combination of THIS YouTube video and THIS documentation, which created a very nice looking date picker:

Android date picker

This weeks goals

  • looking forward to this week I have two main goals I want to accomplish:

1) code refactoring
2) open source contribution

  • I will keep working and create keep everyone updated next week

Conclusion

  • Thank you for taking the time out of your day to read this blog post of mine. If you have any questions or concerns please comment below or reach out to me on Twitter.

Top comments (0)