ExceptionWear (:exclamation::watch:) is very simple library to solve problem of not passing exceptions from Android Wear devices to the phone. So if you release an app for smartwatches to Google Play and it will crash (and it will) you won't get any information about it (sic!).
To start with handling your exceptions, all you need is to add one line to Application
class on Wear device. From now on all your exceptions from smartwatch will be thrown as well on the phone. Plus you can add custom handlers for them!
After receiving exception on a phone you can send a email with log, save it for any crash reporting app etc. - just add own class that implements ExceptionWearHandler
and set using ExceptionDataListenerService.setHandler()
before receiving a crash.
Gradle:
//library:
compile 'pl.tajchert:exceptionwear:0.1.2'
//needed dependency:
compile 'com.google.android.gms:play-services-wearable:+'
Add it to both projects - mobile and wear.
Maven:
<dependency>
<groupId>pl.tajchert</groupId>
<artifactId>exceptionwear</artifactId>
<version>0.1.2</version>
</dependency>
Wear app:
public class WearableApplication extends Application {
public void onCreate() {
//...
ExceptionWear.initialize(this);
}
}
Phone (for custom handler):
public class PhoneApplication extends Application {
public void onCreate() {
//...
ExceptionDataListenerService.setHandler(new CustomExceptionHandler());//need to implements ExceptionWearHandler
}
}
Other sample handlers are already implemented in sample project. There are: Log only handler, sending email, Crashlytics handler.
ExceptionWear binaries and source code can be used according to the Apache License, Version 2.0.
Goes to Sebastian Mauer for that gist (whole library is based on it), and also to: Aleksander Piotrowski, David Vavra.