Android App未在更高版本上运行

时间:2016-10-23 06:47:22

标签: java android dalvik

该应用程序在模拟器(5.1)和我的手机(4.1.2)中正常运行,但是它在打开时崩溃,在蓝色堆栈(4.4.2)和高于4.1的真实手机中“不幸的应用停止” / p>

我在Bluestacks中运行时遇到此错误。尝试更改minsdk版本和appcompact选项。

    10-21 22:27:22.551 12147-12147/player.kri.com.saranplayer I/dalvikvm: Could not find method android.content.Context.getSystemService, referenced from method com.androidhive.musicplayer.MusicPlayerMainActivity.access$super
10-21 22:27:22.551 12147-12147/player.kri.com.saranplayer W/dalvikvm: VFY: unable to resolve virtual method 524: Landroid/content/Context;.getSystemService (Ljava/lang/Class;)Ljava/lang/Object;
10-21 22:27:22.551 12147-12147/player.kri.com.saranplayer D/dalvikvm: VFY: replacing opcode 0x6f at 0x004b
10-21 22:27:22.551 12147-12147/player.kri.com.saranplayer I/dalvikvm: Could not find method android.app.Activity.stopLockTask, referenced from method com.androidhive.musicplayer.MusicPlayerMainActivity.access$super
10-21 22:27:22.551 12147-12147/player.kri.com.saranplayer W/dalvikvm: VFY: unable to resolve virtual method 279: Landroid/app/Activity;.stopLockTask ()V
10-21 22:27:22.551 12147-12147/player.kri.com.saranplayer D/dalvikvm: VFY: replacing opcode 0x6f at 0x00b9
10-21 22:27:22.551 12147-12147/player.kri.com.saranplayer I/dalvikvm: Could not find method android.app.Activity.isInMultiWindowMode, referenced from method com.androidhive.musicplayer.MusicPlayerMainActivity.access$super
10-21 22:27:22.551 12147-12147/player.kri.com.saranplayer W/dalvikvm: VFY: unable to resolve virtual method 102: Landroid/app/Activity;.isInMultiWindowMode ()Z
10-21 22:27:22.551 12147-12147/player.kri.com.saranplayer D/dalvikvm: VFY: replacing opcode 0x6f at 0x00eb
10-21 22:27:22.551 12147-12147/player.kri.com.saranplayer E/dalvikvm: Could not find class 'android.os.PersistableBundle', referenced from method com.androidhive.musicplayer.MusicPlayerMainActivity.access$super
10-21 22:27:22.551 12147-12147/player.kri.com.saranplayer W/dalvikvm: VFY: unable to resolve check-cast 234 (Landroid/os/PersistableBundle;) in Lcom/androidhive/musicplayer/MusicPlayerMainActivity;
10-21 22:27:22.551 12147-12147/player.kri.com.saranplayer D/dalvikvm: VFY: replacing opcode 0x1f at 0x00fc
10-21 22:27:22.551 12147-12147/player.kri.com.saranplayer I/dalvikvm: Could not find method android.content.Context.getColorStateList, referenced from method com.androidhive.musicplayer.MusicPlayerMainActivity.access$super
10-21 22:27:22.551 12147-12147/player.kri.com.saranplayer W/dalvikvm: VFY: unable to resolve virtual method 505: Landroid/content/Context;.getColorStateList (I)Landroid/content/res/ColorStateList;
10-21 22:27:22.551 12147-12147/player.kri.com.saranplayer D/dalvikvm: VFY: replacing opcode 0x6f at 0x010c
10-21 22:27:22.551 12147-12147/player.kri.com.saranplayer I/dalvikvm: Could not find method android.app.Activity.onVisibleBehindCanceled, referenced from method com.androidhive.musicplayer.MusicPlayerMainActivity.access$super
10-21 22:27:22.551 12147-12147/player.kri.com.saranplayer W/dalvikvm: VFY: unable to resolve virtual method 193: Landroid/app/Activity;.onVisibleBehindCanceled ()V
10-21 22:27:22.551 12147-12147/player.kri.com.saranplayer D/dalvikvm: VFY: replacing opcode 0x6f at 0x011c
10-21 22:27:22.551 12147-12147/player.kri.com.saranplayer I/dalvikvm: Could not find method android.content.ContextWrapper.deleteSharedPreferences, referenced from method com.androidhive.musicplayer.MusicPlayerMainActivity.access$super

真的很感谢你的帮助。

1 个答案:

答案 0 :(得分:0)

根据谷歌Android工程师的说法,这是正常的。

请参阅https://code.google.com/p/android/issues/detail?id=198567

当您针对比部署的设备api级别更高的api级别进行编译时会发生这种情况。日志表明,某些方法不可用,虚拟机将用替代实现替换它们。

这只是意味着您有一个方法的引用,该方法在您当前运行的代码的平台上不可用。

要解决您的问题,请编写运行时开关:

if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
    // You can use here an API which was added in Lollipop.
}