Use android-support @Keep annotation to avoid removal of AndroidExceptionPreHandler
Fixes #214 better
diff --git a/README.md b/README.md
index 789d0ea..bd59646 100644
--- a/README.md
+++ b/README.md
@@ -107,9 +107,3 @@
volatile <fields>;
}
```
-
-You also need to keep this class if you build your Android releases with `minifyEnabled true`:
-
-```
--keep class kotlinx.coroutines.experimental.android.AndroidExceptionPreHandler
-```
diff --git a/ui/kotlinx-coroutines-android/build.gradle b/ui/kotlinx-coroutines-android/build.gradle
index d10dc45..fee06f0 100644
--- a/ui/kotlinx-coroutines-android/build.gradle
+++ b/ui/kotlinx-coroutines-android/build.gradle
@@ -1,5 +1,10 @@
+repositories {
+ google()
+}
+
dependencies {
compileOnly 'com.google.android:android:4.1.1.4'
+ compileOnly 'com.android.support:support-annotations:26.1.0'
}
tasks.withType(dokka.getClass()) {
diff --git a/ui/kotlinx-coroutines-android/src/main/kotlin/kotlinx/coroutines/experimental/android/AndroidExceptionPreHandler.kt b/ui/kotlinx-coroutines-android/src/main/kotlin/kotlinx/coroutines/experimental/android/AndroidExceptionPreHandler.kt
index 7bab7b6..762c7be 100644
--- a/ui/kotlinx-coroutines-android/src/main/kotlin/kotlinx/coroutines/experimental/android/AndroidExceptionPreHandler.kt
+++ b/ui/kotlinx-coroutines-android/src/main/kotlin/kotlinx/coroutines/experimental/android/AndroidExceptionPreHandler.kt
@@ -1,9 +1,9 @@
package kotlinx.coroutines.experimental.android
-import kotlinx.coroutines.experimental.CoroutineExceptionHandler
-import java.lang.reflect.Modifier
-import kotlin.coroutines.experimental.AbstractCoroutineContextElement
-import kotlin.coroutines.experimental.CoroutineContext
+import android.support.annotation.*
+import kotlinx.coroutines.experimental.*
+import java.lang.reflect.*
+import kotlin.coroutines.experimental.*
private val getter =
try {
@@ -20,6 +20,7 @@
*
* @suppress This is an internal impl class.
*/
+@Keep
class AndroidExceptionPreHandler :
AbstractCoroutineContextElement(CoroutineExceptionHandler), CoroutineExceptionHandler
{