如何解决这个错误 VFY: unable to resolve virtual method
How to resolve this error VFY: unable to resolve virtual method
我正在使用 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'
}
如何处理这个错误,我试过将编译版本'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) {
// You can use here an API which was added in Lollipop.
}
根据 google Android 工程师的说法,这是正常的。
参考https://code.google.com/p/android/issues/detail?id=198567
当您针对比部署设备 api 级别更高的 api 级别进行编译时,会发生这种情况。日志表明,某些方法不可用,虚拟机将用替代实现替换它们。
Br,
尼克
我有相同的警告,然后是致命的 NoClassDefFoundError。问题可能出自 android-plugin 的多 dex 模式下的 dex 生成文件。所有找不到的 类 都在一个包裹中。该包被分成 2 个 dex 文件。一种解决方案是生成 MainDexList 文件,其中我只包含未解析的 类 ,它们已加入一个 dex 文件。有关详细信息,另请参阅 here。
我正在使用 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'
}
如何处理这个错误,我试过将编译版本'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) {
// You can use here an API which was added in Lollipop.
}
根据 google Android 工程师的说法,这是正常的。
参考https://code.google.com/p/android/issues/detail?id=198567
当您针对比部署设备 api 级别更高的 api 级别进行编译时,会发生这种情况。日志表明,某些方法不可用,虚拟机将用替代实现替换它们。
Br, 尼克
我有相同的警告,然后是致命的 NoClassDefFoundError。问题可能出自 android-plugin 的多 dex 模式下的 dex 生成文件。所有找不到的 类 都在一个包裹中。该包被分成 2 个 dex 文件。一种解决方案是生成 MainDexList 文件,其中我只包含未解析的 类 ,它们已加入一个 dex 文件。有关详细信息,另请参阅 here。