How does google play capture exceptions from our mobile?

☆樱花仙子☆ 提交于 2020-01-15 04:29:06

问题


I am wondering how would a Google play is capable of capturing list of errors occuring in the applications it has and showing it to the developer?

Backdrop: We are trying to replicate an application like Google store? We should maintain a list of enterprise application through our application. We wanted to implement an exception capturing framework through our application that is capable of capturing exception by our list of apps and show and store it in backend.


回答1:


I assume Android applications are tied to Google Play market so that when exceptions occurs, the crash report to be sent to them.

One possible solution would be to let your users implement some kind of library in order to publish apps on your market. That library should do nothing but catch exceptions and send crash reports to your servers (something like ACRA).

Though, as a developer, I don't think this approach is one good, unless you offer something very promising to developers (like app visibility, promotion, etc)




回答2:


I do not know how Google Play does it, but for my needs I create my own java.lang.Thread.UncaughtExceptionHandler:

class MyUncaughtExceptionHandler implements UncaughtExceptionHandler {
    private UncaughtExceptionHandler mDefaultUncaughtExceptionHandler;

    MyUncaughtExceptionHandler() {
        mDefaultUncaughtExceptionHandler = Thread.getDefaultUncaughtExceptionHandler();
    }

    @Override
    public void uncaughtException(Thread aThread, Throwable aThrowable) {
        // do your stuff
        mDefaultUncaughtExceptionHandler.uncaughtException(aThread, aThrowable);
    }
}

And register it in android.app.Application#onCreate.

@Override
public void onCreate() {
    super.onCreate();
    Thread.setDefaultUncaughtExceptionHandler(new UncaughtExceptionHandler());
}


来源:https://stackoverflow.com/questions/15565926/how-does-google-play-capture-exceptions-from-our-mobile

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!