使用 android on click 方法启动 Intent 后应用程序崩溃

Posted

技术标签:

【中文标题】使用 android on click 方法启动 Intent 后应用程序崩溃【英文标题】:App crashed after starting an intent using a android on click method 【发布时间】:2016-08-10 18:04:59 【问题描述】:

我有一个 android on click 函数,它使用 startActivaty() 方法启动一个意图 当我执行该功能时,应用程序一次又一次地崩溃。这是错误代码04-18 23:15:09.012 23801-23801/? I/SELinux: Function: selinux_android_load_priority , priority [3] , priority version is VE=SEPF_SHV-E210S_4.4.4_0028 04-18 23:15:09.012 23801-23801/? E/dalvikvm: >>>>> Normal User 04-18 23:15:09.012 23801-23801/? E/dalvikvm: >>>>> com.example.user.multiplication [ userId:0 | appId:10167 ] 04-18 23:15:09.012 23801-23801/? D/dalvikvm: Late-enabling CheckJNI 04-18 23:15:09.162 23801-23801/com.example.user.multiplication W/dalvikvm: VFY: unable to find class referenced in signature (Landroid/view/SearchEvent;) 04-18 23:15:09.162 23801-23801/com.example.user.multiplication I/dalvikvm: Could not find method android.view.Window$Callback.onSearchRequested, referenced from method android.support.v7.view.WindowCallbackWrapper.onSearchRequested 04-18 23:15:09.162 23801-23801/com.example.user.multiplication W/dalvikvm: VFY: unable to resolve interface method 18817: Landroid/view/Window$Callback;.onSearchRequested (Landroid/view/SearchEvent;)Z 04-18 23:15:09.162 23801-23801/com.example.user.multiplication D/dalvikvm: VFY: replacing opcode 0x72 at 0x0002 04-18 23:15:09.162 23801-23801/com.example.user.multiplication I/dalvikvm: Could not find method android.view.Window$Callback.onWindowStartingActionMode, referenced from method android.support.v7.view.WindowCallbackWrapper.onWindowStartingActionMode 04-18 23:15:09.162 23801-23801/com.example.user.multiplication W/dalvikvm: VFY: unable to resolve interface method 18821: Landroid/view/Window$Callback;.onWindowStartingActionMode (Landroid/view/ActionMode$Callback;I)Landroid/view/ActionMode; 04-18 23:15:09.162 23801-23801/com.example.user.multiplication D/dalvikvm: VFY: replacing opcode 0x72 at 0x0002 04-18 23:15:09.192 23801-23801/com.example.user.multiplication D/MultiPhoneWindow: generateLayout : sMinimumStackBoundForPortraitOrientRect(0, 0 - 0, 0), sMinimumStackBoundForLandscapeOrient=Rect(0, 0 - 0, 0) 04-18 23:15:09.212 23801-23801/com.example.user.multiplication I/dalvikvm: Could not find method android.content.res.TypedArray.getChangingConfigurations, referenced from method android.support.v7.widget.TintTypedArray.getChangingConfigurations 04-18 23:15:09.212 23801-23801/com.example.user.multiplication W/dalvikvm: VFY: unable to resolve virtual method 415: Landroid/content/res/TypedArray;.getChangingConfigurations ()I 04-18 23:15:09.212 23801-23801/com.example.user.multiplication D/dalvikvm: VFY: replacing opcode 0x6e at 0x0002 04-18 23:15:09.212 23801-23801/com.example.user.multiplication I/dalvikvm: Could not find method android.content.res.TypedArray.getType, referenced from method android.support.v7.widget.TintTypedArray.getType 04-18 23:15:09.212 23801-23801/com.example.user.multiplication W/dalvikvm: VFY: unable to resolve virtual method 437: Landroid/content/res/TypedArray;.getType (I)I 04-18 23:15:09.212 23801-23801/com.example.user.multiplication D/dalvikvm: VFY: replacing opcode 0x6e at 0x0002 04-18 23:15:09.257 23801-23833/com.example.user.multiplication V/MediaPlayer: decode(53, 390064, 113425) 04-18 23:15:09.257 23801-23831/com.example.user.multiplication V/MediaPlayer: decode(52, 315460, 74558) 04-18 23:15:09.332 23801-23801/com.example.user.multiplication D/libEGL: loaded /system/lib/egl/libEGL_mali.so 04-18 23:15:09.337 23801-23801/com.example.user.multiplication D/libEGL: loaded /system/lib/egl/libGLESv1_CM_mali.so 04-18 23:15:09.342 23801-23801/com.example.user.multiplication D/libEGL: loaded /system/lib/egl/libGLESv2_mali.so 04-18 23:15:09.402 23801-23801/com.example.user.multiplication D/OpenGLRenderer: Enabling debug mode 0 我没看懂代码。请帮忙

【问题讨论】:

【参考方案1】:

请提供您的主要活动和主要布局的源代码,以获得更好的答案(甚至可能是修复!)。

但是对于我可以在日志中检查的内容,您正在尝试调用您未在类中提供实现的方法(可能来自布局文件)(很可能在您的主要活动中)。基于:

Could not find method android.view.Window$Callback.onSearchRequested, referenced from method android.support.v7.view.WindowCallbackWrapper.onSearchRequested

【讨论】:

以上是关于使用 android on click 方法启动 Intent 后应用程序崩溃的主要内容,如果未能解决你的问题,请参考以下文章

Android studio初次安装启动时弹出unable to access android sdk add-on list提示的解决方法

Click on 与click有区别吗?

如何在 Ruby on Rails 中使用带有 form.select 的 jquery .click() 方法?

微信iOS端无法执行jquery on()方法

jQuery on()方法使用

事件绑定方法和性能 $(document).on("click", "#id", fn) VS $("#id").on("clic