Android Studio: InvalidVirtualFileAccessException

2020-07-18 06:08发布

问题:

I'm trying to preview an xml layout (any xml layout) in my app. I'm using Android Studio 1.5 Preview 2. I'm getting this error over and over:

InvalidVirtualFileAccessException: Accessing invalid virtual file: file://D:/Scott/Android/Studio/MyApp/app/build/intermediates/classes/debug/com/scott/myapp/R$styleable.class; original:134487; found:-

Details:

Accessing invalid virtual file: file://D:/Scott/Android/Studio/MyApp/app/build/intermediates/classes/debug/com/scott/myapp/R$styleable.class; original:134487; found:-
com.intellij.openapi.vfs.InvalidVirtualFileAccessException: Accessing invalid virtual file: file://D:/Scott/Android/Studio/MyApp/app/build/intermediates/classes/debug/com/scott/myapp/R$styleable.class; original:134487; found:-
    at com.intellij.openapi.vfs.newvfs.persistent.PersistentFSImpl.getFileId(PersistentFSImpl.java:332)
    at com.intellij.openapi.vfs.newvfs.persistent.PersistentFSImpl.getTimeStamp(PersistentFSImpl.java:319)
    at com.intellij.openapi.vfs.newvfs.impl.VirtualFileSystemEntry.getTimeStamp(VirtualFileSystemEntry.java:228)
    at org.jetbrains.android.uipreview.ModuleClassLoader.isUpToDate(ModuleClassLoader.java:357)
    at org.jetbrains.android.uipreview.ModuleClassLoader.get(ModuleClassLoader.java:383)
    at org.jetbrains.android.uipreview.ViewLoader.getModuleClassLoader(ViewLoader.java:242)
    at org.jetbrains.android.uipreview.ViewLoader.loadAndParseRClass(ViewLoader.java:515)
    at org.jetbrains.android.uipreview.ViewLoader.loadAndParseRClassSilently(ViewLoader.java:495)
    at com.android.tools.idea.rendering.LayoutlibCallbackImpl.loadAndParseRClass(LayoutlibCallbackImpl.java:636)
    at com.android.tools.idea.rendering.RenderTask.<init>(RenderTask.java:153)
    at com.android.tools.idea.rendering.RenderService.createTask(RenderService.java:200)
    at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager.doRender(AndroidLayoutPreviewToolWindowManager.java:649)
    at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager.access$1700(AndroidLayoutPreviewToolWindowManager.java:80)
    at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager$7$1.run(AndroidLayoutPreviewToolWindowManager.java:594)
    at com.intellij.openapi.progress.impl.CoreProgressManager$2.run(CoreProgressManager.java:152)
    at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:452)
    at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:402)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:54)
    at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:137)
    at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager$7.run(AndroidLayoutPreviewToolWindowManager.java:589)
    at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:320)
    at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:310)
    at com.intellij.util.ui.update.MergingUpdateQueue$2.run(MergingUpdateQueue.java:254)
    at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:269)
    at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:227)
    at com.intellij.util.ui.update.MergingUpdateQueue.run(MergingUpdateQueue.java:217)
    at com.intellij.util.concurrency.QueueProcessor.runSafely(QueueProcessor.java:238)
    at com.intellij.util.Alarm$Request$1.run(Alarm.java:351)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:744)

Anyone else have this error?

Notes:

  • This seems to be specific to this project, as I'm able to render xml layouts in another project using the same version
  • I've tried ReBuilding the project, but it hasn't helped

回答1:

It's a bug of the current Android Studio 1.5 version.

Today the 1.5-RC1 have been released and the bug is still present. Work with the latest stable version 1.4 if you dont want have this kind of problem

Here the issue i filled for the bug: https://code.google.com/p/android/issues/detail?id=193836&thanks=193836&ts=1447285466



回答2:

If anyone is having this issue in 2.1.2, first try closing your Android Studio project and reopening it. That fixed the error immediately for me after about an hour of trying to debug.



回答3:

It happened to me when I've removed and reinstalled some SDK components. I simply restarted and Android Studio, build->clean project, and build->build project.