0

We are a team of developers and just started using Crashlytics. Most of us have the exact same model of device that is used for testing.

When a crash happens, how can we identify which device it relates to. In other words, how do we know if a crash is on the device of Developer A or B.

Pati
  • 26
  • 3
  • 1
    You can set custom strings which are send with stacktrace to Fabric. Take a look at `Crashlytics.setString()`. – skywall May 31 '17 at 08:30
  • I have seen that in the docs. But since the codebase is common (using Git), how exactly does each have a separate custom string. – Pati May 31 '17 at 08:34
  • 1
    If you have some kind of login in your app, you might me fine with user id. If not, you can same your unique id to `local.properties` file and propagate it directly to Java. Examine this https://stackoverflow.com/questions/21999829/how-do-i-read-properties-defined-in-local-properties-in-build-gradle. – skywall May 31 '17 at 08:46

1 Answers1

2

The most correct way to distinct devices one from another is by sending IMEI when crash happens. There aren't two identical IMEIs in the world.

public void sendImei(Context vContext) {

    String imei;
    TelephonyManager tm = (TelephonyManager) vContext.getSystemService(Context.TELEPHONY_SERVICE);
    if (tm != null)
        imei = tm.getDeviceId();
    if (imei == null || imei.length() == 0)
        imei = Secure.getString(vContext.getContentResolver(), Secure.ANDROID_ID);

    Crashlytics.setUserIdentifier(String.valueOf(imei));

}
tompadre
  • 797
  • 7
  • 22
  • We have thought of this but it is not very identifiable. We use it for other purposes. There are some views that this may not be a good way to identify the device though. Do not know enough to deliberate though. Thus, for now, we have used the login id (which we also store in the local database). – Pati Jun 06 '17 at 15:46