簡體   English   中英

如何解決此錯誤VFY:無法解析虛方法

[英]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.
}

根據谷歌Android工程師的說法,這是正常的。

請參閱https://code.google.com/p/android/issues/detail?id=198567

當您針對比部署的設備api級別更高的api級別進行編譯時,會發生這種情況。 日志表明,某些方法不可用,虛擬機將使用替代實現替換它們。

Br,尼克

我有相同的警告,然后致命的NoClassDefFoundError。 問題可以來自android-plugin的多索引模式中的dex生成的文件。 所有無法找到的類都在一個包中。 該軟件包分為2個dex文件。 一個解決方案是生成MainDexList文件,其中我只包含未解析的類,這些類連接到一個dex文件。 有關詳細信息,請參見此處

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM