如何解决此错误VFY:无法parsing虚拟方法

我正在使用android studio 2.0,在上次我升级jdk 7到jdk 8,我正在对文件gradle进行一些更改,但现在我得到这个错误

E/InstantRun: Could not find slices in APK; aborting. I/dalvikvm: Could not find method android.content.Context.getSystemService, referenced from method com.mstr.malik.elbalaapps.ControlPanel.access$super W/dalvikvm: VFY: unable to resolve virtual method 435: Landroid/content/Context;.getSystemService (Ljava/lang/Class;)Ljava/lang/Object; D/dalvikvm: VFY: replacing opcode 0x6f at 0x004b I/dalvikvm: Could not find method android.app.Activity.stopLockTask, referenced from method com.mstr.malik.elbalaapps.ControlPanel.access$super W/dalvikvm: VFY: unable to resolve virtual method 231: Landroid/app/Activity;.stopLockTask ()V D/dalvikvm: VFY: replacing opcode 0x6f at 0x00b9 E/dalvikvm: Could not find class 'android.os.PersistableBundle', referenced from method com.mstr.malik.elbalaapps.ControlPanel.access$super W/dalvikvm: VFY: unable to resolve check-cast 224 (Landroid/os/PersistableBundle;) in Lcom/mstr/malik/elbalaapps/ControlPanel; D/dalvikvm: VFY: replacing opcode 0x1f at 0x00f1 I/dalvikvm: Could not find method android.content.Context.getColorStateList, referenced from method com.mstr.malik.elbalaapps.ControlPanel.access$super W/dalvikvm: VFY: unable to resolve virtual method 417: Landroid/content/Context;.getColorStateList (I)Landroid/content/res/ColorStateList; D/dalvikvm: VFY: replacing opcode 0x6f at 0x0101 I/dalvikvm: Could not find method android.app.Activity.onVisibleBehindCanceled, referenced from method com.mstr.malik.elbalaapps.ControlPanel.access$super W/dalvikvm: VFY: unable to resolve virtual method 154: Landroid/app/Activity;.onVisibleBehindCanceled ()V D/dalvikvm: VFY: replacing opcode 0x6f at 0x0111 I/dalvikvm: Could not find method android.app.Activity.onWindowStartingActionMode, referenced from method com.mstr.malik.elbalaapps.ControlPanel.access$super W/dalvikvm: VFY: unable to resolve virtual method 158: Landroid/app/Activity;.onWindowStartingActionMode (Landroid/view/ActionMode$Callback;I)Landroid/view/ActionMode; D/dalvikvm: VFY: replacing opcode 0x6f at 0x0137 E/dalvikvm: Could not find class 'android.os.PersistableBundle', referenced from method com.mstr.malik.elbalaapps.ControlPanel.access$super W/dalvikvm: VFY: unable to resolve check-cast 224 (Landroid/os/PersistableBundle;) in Lcom/mstr/malik/elbalaapps/ControlPanel; D/dalvikvm: VFY: replacing opcode 0x1f at 0x019a 

这是一个gradle文件

 apply plugin: 'com.android.application' android { compileSdkVersion 23 buildToolsVersion "24.0.0 rc3" defaultConfig { applicationId "com.mstr.malik.elbalaapps" minSdkVersion 18 targetSdkVersion 23 versionCode 1 versionName "1.0" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) testCompile 'junit:junit:4.12' compile 'com.android.support:appcompat-v7:23.3.0' } 

如何处理错误,我试图chanfe编译编译'com.android.support:appcompat-v7:23.3.0'编译'com.android.support:appcompat-v7:23.0.0'它也崩溃,我该怎么办? 提前致谢

Solutions Collecting From Web of "如何解决此错误VFY:无法parsing虚拟方法"

如果您在运行时检查Android版本,则可以放心地忽略此警告。 这只意味着你有一个方法的引用,在你的代码目前运行的平台上是不可用的。 您只需确保在旧版平台上不使用较新的API。 通常林特会警告你,如果你在发布版本中做错了什么。 只要你记住,你不必担心。

就像这样一个运行时开关的例子:

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

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

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

如果您编译的API级别高于所部署的设备api级别,则会发生这种情况。 这些日志表明,有些方法不可用,虚拟机将用替代实现replace它们。

Br,Nick

我有相同的警告,然后致命的NoClassDefFoundError。 这个问题可以从dex生成的文件在android-plugin的multi-dex模式下进行。 所有无法find的类都在一个包中。 该软件包被分成两个dex文件。 一个解决scheme是生成MainDexList文件,其中我只包含未解决的类,它们被join到一个dex文件中。 欲了解更多详情,请参阅这里 。