dependencies { // most often used way, enable notification to notify block event implementation 'com.github.markzhai:blockcanary-android:1.5.0'
// this way you only enable BlockCanary in debug package // debugImplementation 'com.github.markzhai:blockcanary-android:1.5.0' // releaseImplementation 'com.github.markzhai:blockcanary-no-op:1.5.0' }
Step2. 在Application中注册
1 2 3 4 5 6 7 8
publicclassDemoApplicationextendsApplication{ @Override publicvoidonCreate(){ // ... // Do it on main process BlockCanary.install(this, new BlockCanaryContext()).start(); } }
for (;;) { // ... // This must be in a local variable, in case a UI event sets the logger final Printer logging = me.mLogging; if (logging != null) { logging.println(">>>>> Dispatching to " + msg.target + " " + msg.callback + ": " + msg.what); }