title: JobCancellationException StandaloneCoroutine was cancelled
body: <p>Since we are using Coroutines (1.3.5 used) we have a lot of crash : <strong>JobCancellationException - StandaloneCoroutine was cancelled</strong>.</p>
  
  <p>I read a lot of thread about theses problems and I tried a lot of solution in production but crashes always occurs.</p>
  
  <p>In all our viewmodels we are using the viewmodelscope so it's ok. </p>
  
  <p>But in our data layer we need to launch a tracking events which are <em>fire and forget</em> task. In first step we used a <code>GlobalScope.launch</code>. I was thinking the CancelletationException was due to this global scope so I removed it and create an extension in the data layer with using a <code>SupervisorJob</code> and a <code>CoroutineExceptionHandler</code>:</p>
  
  <pre><code>private val appScope = CoroutineScope(Dispatchers.Default + SupervisorJob())
  private val coroutineExceptionHandler by lazy { CoroutineExceptionHandler { _, throwable -&gt; logw("Error occurred inside Coroutine.", throwable) } }
  
  fun launchOnApp(block: suspend CoroutineScope.() -&gt; Unit) {
      appScope.launch(coroutineExceptionHandler) { block() }
  }
  </code></pre>
  
  <p>But I always saw crashes with this code. Do I need to use <code>cancelAndJoin</code> method? Which strategy I can use with a clean archi and this kind of work please?</p>
  
  <p>Thanks in advance</p>