自学内容网 自学内容网

android studio升级后编译发现不兼容回到旧版本还是不兼容

Error

Running Gradle task 'assembleDevDebug'...

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':gradle:compileGroovy'.
> BUG! exception in phase 'semantic analysis' in source unit '/Users/dyh/development/flutter/packages/flutter_tools/gradle/src/main/groovy/app_plugin_loader.groovy' Unsupported class file major version 65

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 3s

┌─ Flutter Fix ────────────────────────────────────────────────────────────────────────────────────┐
│ [!] Your project's Gradle version is incompatible with the Java version that Flutter is using    │
│ for Gradle.                                                                                      │
│                                                                                                  │
│ If you recently upgraded Android Studio, consult the migration guide at                          │
│ docs.flutter.dev/go/android-java-gradle-error.                                                   │
│                                                                                                  │
│ Otherwise, to fix this issue, first, check the Java version used by Flutter by running `flutter  │
│ doctor --verbose`.                                                                               │
│                                                                                                  │
│ Then, update the Gradle version specified in                                                     │
│ /Users/dyh/demo/pixcheese/android/gradle/wrapper/gradle-wrapper.properties to be compatible with │
│ that Java version. See the link below for more information on compatible Java/Gradle versions:   │
│ https://docs.gradle.org/current/userguide/compatibility.html#java                                │
│                                                                                                  │
│                                                                                                  │
└──────────────────────────────────────────────────────────────────────────────────────────────────┘
Error: Gradle task assembleDevDebug failed with exit code 1

解决方法参考

把新版本 Android studio的丢入废纸篓

不然会报重复gradle错误

清理并重建项目

在android目录下执行

./gradlew clean build

删除gradle缓存

删除整个 .gradle/caches/ 目录

rm -rf ~/.gradle/caches/

禁用 Gradle 守护进程

有时候,Gradle 守护进程会持有旧的缓存信息,尝试禁用它:

./gradlew --stop
./gradlew build --no-daemon

原文地址:https://blog.csdn.net/DyuanH/article/details/143752743

免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!