flutter 报错external_file_lib_dex_

2020-07-20  本文已影响0人  小轩言

周一刚上班,从新运行了上周五改完的app,结果遇到了下面的错误

Caused by: java.nio.file.NoSuchFileException: /Users/csxsky/PMS/flutter_pms/build/intermediates/external_file_lib_dex_archives/debug/out
    at sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:79)
    at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:97)
    at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:102)
    at sun.nio.fs.WindowsDirectoryStream.<init>(WindowsDirectoryStream.java:86)
    at sun.nio.fs.WindowsFileSystemProvider.newDirectoryStream(WindowsFileSystemProvider.java:518)
    at java.nio.file.Files.newDirectoryStream(Files.java:457)
    at java.nio.file.Files.list(Files.java:3451)
    at com.android.build.gradle.internal.tasks.DexMergingParams.getAllDexFiles(DexMergingTask.kt:502)
    at com.android.build.gradle.internal.tasks.DexMergingTaskRunnable.run(DexMergingTask.kt:423)
    ... 28 more

本来上周五还好好的,就找了一下资料,发现网上的资料和解决办法很少,在此记录一下我这里成功的方案

I encountered this same error in a React Native project I am working on. I was able to resolve the issue through the following. Be sure to replace <PROJECT_NAME> below with your actual project name.

Within Android Studio, select File > Invalid Cache and Restart.
Open your project directory in your terminal.
rm -rf .gradle
rm -rf android/.gradle android/.idea
rm android/app/app.iml android/<PROJECT_NAME>.iml
After doing this, I was able to open my project in Android Studio and successfully build. I had tried all but step 3 a few times without success, so my belief is that step 3 and the top-level .gradle directory in my project was the primary issue. I'm not sure how it got there.

One additional note, React Native projects place all of the Android-specific code inside an android directory. So, if your project is not a React Native project, and instead a traditional Android project, the paths I outlined for removal may be different (i.e. they wouldn't be underneath android/).
image.png

按理解就是gradle的问题,删了然后从新编译就好了

上一篇下一篇

猜你喜欢

热点阅读