Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Crashlytics - restrict network access

Tags:

I've been working for a while around a lack of ability to restrict Crashlytics network usage under certain conditions. For example - on roaming, on metered networks and so on..

According to SDK documentation, only two options I found addressing somehow this:

  • "Opt Out" on runtime by simply not initialize Crashlytics

  • built-in User consent dialog before sending a crash report

This API's are very limited, because:

  • Not initialize Crashlytics not only prevents network access but also prevents any chance Crashlytics will save locally the crash report so that eventually the event will be sent. Not to mention there is no good way to opt out in runtime, besides overriding brutally the Thread.setUncaughtExceptionHandler

  • consent dialog not making any sense to the user if a crash happens in the background.

My question basically: Am I missing something? Is there any way to restrict Crashlytics network access?

My motivation comes from a need to prevent situation my app uses network bandwidth potentially can cost money to the user under certain conditions, although "cellular network" or "use data over roaming" device settings are enabled.

like image 653
Tal Kanel Avatar asked Jul 07 '18 17:07

Tal Kanel


People also ask

How does Crashlytics work Android?

Crashlytics creates a exception handler that intercepts the exceptions that weren't caught and does something with them but it also sends the exception to the previous exception handler, that's why the app stills crashes.

How Crashlytics works?

Firebase Crashlytics is a lightweight, realtime crash reporter that helps you track, prioritize, and fix stability issues that erode your app quality. Crashlytics saves you troubleshooting time by intelligently grouping crashes and highlighting the circumstances that lead up to them.

Is Crashlytics real time?

Firebase Crashlytics, a real time crash reporting tool, helps you prioritize and fix your most pervasive crashes based on the impact on real users. Crashlytics also easily integrates into your Android, iOS, macOS, tvOS, and watchOS apps.


1 Answers

There is not a way to restrict the internet usage for Crashlytics in an application. But how I would fix it is to either give the user information that Crashlytics is using roaming or just save the crash report locally and send them once the user in connected with a wifi network. Also you could give the user the choice if he prefers to save the crash reports locally or send them right away over roaming.

  1. Save the ErrorLog locally on the device
  2. Upload the ErrorLog once a connection with a wifi is established

You should be able to use the ConnectivityManager to get the state of the Wi-Fi adapter. From there you can check if it is connected or even available.

ConnectivityManager connManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo mWifi = connManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);

if (mWifi.isConnected()) {
    // post error logs
}
like image 74
Gucci Avatar answered Sep 20 '22 09:09

Gucci