android / android-ktx

A set of Kotlin extensions for Android app development.
https://android.github.io/android-ktx/core-ktx/
7.46k stars 563 forks source link

systemService<ClipboardManager>() Crash - NoSuchMethodError #565

Closed 0xhyperdan closed 6 years ago

0xhyperdan commented 6 years ago

SUPPORTED_64_BIT_ABIS=[Ljava.lang.String;@275308c2 versionCode=1 BOARD=full_oppo6755_15111 BOOTLOADER=unknown TYPE=user ID=LMY47I TIME=1525878372000 BRAND=OPPO TAG=Build SERIAL=8TVK4DOJ99999999 HARDWARE=mt6755 SUPPORTED_ABIS=[Ljava.lang.String;@131206d3 CPU_ABI=arm64-v8a RADIO=unknown IS_DEBUGGABLE=false MANUFACTURER=OPPO SUPPORTED_32_BIT_ABIS=[Ljava.lang.String;@1f84efa4 TAGS=dev-keys CPU_ABI2= UNKNOWN=unknown USER=root FINGERPRINT=OPPO/R9m/R9:5.1/LMY47I/1515760704:user/release-keys HOST=ubuntu-121-206 PRODUCT=R9m versionName=1.0.0 DISPLAY=R9m_11_A.46_180509 MODEL=OPPO R9m DEVICE=R9 java.lang.NoSuchMethodError: No virtual method getSystemService(Ljava/lang/Class;)Ljava/lang/Object; in class Landroid/content/Context; or its super classes (declaration of 'android.content.Context' appears in /system/framework/framework.jar:classes2.dex) at com.baichang.consumer.home.invite.InviteActivity.getClipboard(InviteActivity.kt:85) at com.baichang.consumer.home.invite.InvitePresenter.copy(InvitePresenter.kt:138) at com.baichang.consumer.home.invite.InviteActivity$onCreate$3.doResume(InviteActivity.kt:36) at com.baichang.consumer.home.invite.InviteActivity$onCreate$3.invoke(InviteActivity.kt) at com.baichang.consumer.home.invite.InviteActivity$onCreate$3.invoke(InviteActivity.kt:25) at org.jetbrains.anko.sdk25.coroutines.Sdk25CoroutinesListenersWithCoroutinesKt$onClick$1$1.doResume(ListenersWithCoroutines.kt:285) at kotlin.coroutines.experimental.jvm.internal.CoroutineImpl.resume(CoroutineImpl.kt:54) at kotlinx.coroutines.experimental.DispatchedContinuation$resume$1.run(CoroutineDispatcher.kt:171) at android.os.Handler.handleCallback(Handler.java:815) at android.os.Handler.dispatchMessage(Handler.java:104) at android.os.Looper.loop(Looper.java:224) at android.app.ActivityThread.main(ActivityThread.java:5958) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1113) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:879)

0xhyperdan commented 6 years ago

getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager no problem.

JakeWharton commented 6 years ago

This method requires API 23 or newer. You have to be using the 3.2 alphas for lint to warn, or the next alpha of the 1.0.0 versions which uses ContextCompat and has no API restrictions.

0xhyperdan commented 6 years ago

thank you very much.