如何解决此错误VFY:无法解析虚方法 [英] How to resolve this error VFY: unable to resolve virtual method

查看:657
本文介绍了如何解决此错误VFY:无法解析虚方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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



< pre class =lang-none prettyprint-override> E / InstantRun:无法在APK中找到切片;中止。
I / dalvikvm:找不到方法android.content.Context.getSystemService,从方法com.mstr.malik.elbalaapps.ControlPanel.access引用$ super
W / dalvikvm:VFY:无法解析虚拟方法435:Landroid / content / Context; .getSystemService(Ljava / lang / Class;)Ljava / lang / Object;
D / dalvikvm:VFY:将代码0x6f替换为0x004b
I / dalvikvm:找不到方法android.app.Activity.stopLockTask,从方法com.mstr.malik.elbalaapps.ControlPanel.access $引用超
W / dalvikvm:VFY:无法解析虚方法231:Landroid / app / Activity; .stopLockTask()V
D / dalvikvm:VFY:将操作码0x6f替换为0x00b9
E / dalvikvm:找不到类'android.os.PersistableBundle',从方法com.mstr.malik.elbalaapps.ControlPanel.access引用$ super
W / dalvikvm:VFY:无法解析check-cast 224(Landroid / os / PersistableBundle;)在Lcom / mstr / malik / elbalaapps / ControlPanel中;
D / dalvikvm:VFY:将代码0x1f替换为0x00f1
I / dalvikvm:找不到方法android.content.Context.getColorStateList,从方法com.mstr.malik.elbalaapps.ControlPanel.access $引用超
W / dalvikvm:VFY:无法解析虚方法417:Landroid / content / Context; .getColorStateList(I)Landroid / content / res / ColorStateList;
D / dalvikvm:VFY:将代码0x6f替换为0x0101
I / dalvikvm:找不到方法android.app.Activity.onVisibleBehindCanceled,从方法com.mstr.malik.elbalaapps.ControlPanel.access $引用超
W / dalvikvm:VFY:无法解析虚方法154:Landroid / app / Activity; .onVisibleBehindCanceled()V
D / dalvikvm:VFY:将操作码0x6f替换为0x0111
I / dalvikvm:找不到方法android.app.Activity.onWindowStartingActionMode,从方法com.mstr.malik.elbalaapps.ControlPanel.access引用$ super
W / dalvikvm:VFY:无法解析虚方法158:Landroid / app /Activity;.onWindowStartingActionMode(Landroid / view / ActionMode $ Callback; I)Landroid / view / ActionMode;
D / dalvikvm:VFY:将代码0x6f替换为0x0137
E / dalvikvm:找不到类'android.os.PersistableBundle',从方法com.mstr.malik.elbalaapps.ControlPanel.access $中引用超
W / dalvikvm:VFY:无法解决Lcom / mstr / malik / elbalaapps / ControlPanel中的check-cast 224(Landroid / os / PersistableBundle;);
D / dalvikvm:VFY:将操作码0x1f替换为0x019a

这是gradle文件

  apply plugin:'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion24.0.0 rc3

defaultConfig {
applicationIdcom.mstr.malik.elbalaapps
minSdkVersion 18
targetSdkVersion 23
versionCode 1
versionName1.0
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),' proguard-rules.pro'
}
}
}

依赖项{
编译fileTree(dir:'libs',包括:['*。 jar'])
testCompile'junit:junit:4.12'
compile'c​​om.android.support:appcompat-v7:23.3.0'
}

如何处理错误,我试过c hanfe版本的编译编译'com.android.support:appcompat-v7:23.3.0'来编译'com.android.support:appcompat-v7:23.0.0'它也崩溃了,我怎么能这样做?
提前感谢

解决方案

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



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

  if(Build.VERSION.SDK_INT> = Build.VERSION_CODES.LOLLIPOP){
//你可以在这里使用在Lollipop中添加的API 。
}


I am using android studio 2.0 and in last time I upgrade jdk 7 to jdk 8 and I'm making some changes to file gradle but now I am getting this error

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

An this is gradle file

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'
}

How can I handle the error, I have tried to chanfe version of compile compile 'com.android.support:appcompat-v7:23.3.0' to compile 'com.android.support:appcompat-v7:23.0.0' It also crash, How can I do it? thanks in advance

解决方案

If you check in runtime the Android version you can safely ignore this warnings. It just means that you have a reference to a method which is not available on that platform where you code currently runs on. You just need to make sure that you don't use newer APIs on older platforms. Normally lint will warn you if you do something wrong in release builds. As long you keep that in mind you don't need to worry about it.

Just as an example for such an runtime switch:

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

这篇关于如何解决此错误VFY:无法解析虚方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆