执行App时出现此类错误。
我的代码在支持库24.2.0(Linux操作系统中的Android工作室)中工作,当我在Windows操作系统中运行此代码时出现了一些错误,对于该解决方案,我将支持库升级到25.0.0并且它解决,但现在提到下面提到的错误。
compileSdkVersion = 25
buildToolsVersion = '25.0.0'
supportLibraryVersion = '25.0.0'
targetSdkVersion = 25
E/UncaughtException: java.lang.NoSuchMethodError: No static method isCtrlPressed(Landroid/view/KeyEvent;)Z in class Landroid/support/v4/view/KeyEventCompatHoneycomb; or its super classes (declaration of 'android.support.v4.view.KeyEventCompatHoneycomb' appears in /data/app/com.xxx/base.apk:classes23.dex)
at android.support.v4.view.KeyEventCompat$HoneycombKeyEventVersionImpl.isCtrlPressed(KeyEventCompat.java:120)
at android.support.v4.view.KeyEventCompat.isCtrlPressed(KeyEventCompat.java:197)
at android.support.v7.app.AppCompatActivity.dispatchKeyEvent(AppCompatActivity.java:532)
at android.support.v7.view.WindowCallbackWrapper.dispatchKeyEvent(WindowCallbackWrapper.java:57)
at android.support.v7.app.AppCompatDelegateImplBase$AppCompatWindowCallbackBase.dispatchKeyEvent(AppCompatDelegateImplBase.java:315)
at com.android.internal.policy.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:2310)
at android.view.ViewRootImpl$ViewPostImeInputStage.processKeyEvent(ViewRootImpl.java:4127)
at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4089)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3642)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3695)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3661)
at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3787)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3669)
at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:3844)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3642)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3695)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3661)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3669)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3642)
at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:5922)
at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:5896)
at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:5857)
at android.view.ViewRootImpl$ViewRootHandler.handleMessage(ViewRootImpl.java:3434)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)`
答案 0 :(得分:0)
我解决了这个问题。 确保您的buildToolVersion,CompileSdkVersion和targetSdkVersion与您的支持库匹配。
在以下配置中,我收到错误,
compileSdkVersion = 24
buildToolsVersion = '24.0.2'
targetSdkVersion = 24
supportLibraryVersion = '24.2.0'
所以,我更新到了
compileSdkVersion = 25
buildToolsVersion = '25.0.0'
targetSdkVersion = 25
supportLibraryVersion = '25.0.1'
这解决了我的问题。确保它必须与主要版本版本匹配。