当前位置: 首页 > 知识库问答 >
问题:

Flutter BUG!阶段“语义分析”错误中的异常

庄萧迟
2023-03-14

经过多次搜索并试图解决这个问题,最终我不能,当我试图在真正的手机上运行应用程序时,我得到这个错误:

失败:构建失败,但有例外。

  • 出了什么问题:无法打开设置文件“C:\项目\扑腾\埃尔穆斯塔法\android\settings.gradle”的设置通用类缓存(C:\用户\Mahdi MyName.gradle\caches\6.5\scripts\bq3hllkgb26p0nrblf5gh8d37\settings6418c6d726070f323dbddda2aadc82ef)。

错误!源单元“BuildScript”中的阶段“语义分析”中的异常 不受支持的类文件主要版本 60

>

  • 尝试:使用 --堆栈跟踪选项运行以获取堆栈跟踪。使用 --info 或 --调试选项运行以获取更多日志输出。运行 --scan 以获取完整的见解。

    在 https://help.gradle.org 获得更多帮助

    构建失败3m43s异常:Gradle任务程序集调试失败,退出代码1

    第一次我检查了线下,我注意到我没有:

    build.parallel=true
    

    gradle version in \gradle\wrapper\gradle-wrapper.properties 是:

    distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip
    

    我清理了缓存文件夹:

    rm -rf $HOME/.gradle/caches/
    rm -rf $PROJECT/.gradle/caches/ && rm -rf $PROJECT/build/
    

    flutter run--debug命令的结果:

    [ +115 ms] executing: [G:\android\flutter/] git -c log.showSignature=false log -n 1 --pretty=format:%H
    [+1338 ms] Exit code 0 from: git -c log.showSignature=false log -n 1 --pretty=format:%H
    [   +1 ms] 1d9032c7e1d867f071f2277eb1673e8f9b0274e3
    [   +1 ms] executing: [G:\android\flutter/] git tag --points-at 1d9032c7e1d867f071f2277eb1673e8f9b0274e3
    [  +92 ms] Exit code 0 from: git tag --points-at 1d9032c7e1d867f071f2277eb1673e8f9b0274e3
    [        ] 2.0.6
    [  +62 ms] executing: [G:\android\flutter/] git rev-parse --abbrev-ref --symbolic @{u}
    [  +46 ms] Exit code 0 from: git rev-parse --abbrev-ref --symbolic @{u}
    [        ] origin/stable
    [        ] executing: [G:\android\flutter/] git ls-remote --get-url origin
    [  +42 ms] Exit code 0 from: git ls-remote --get-url origin
    [        ] https://github.com/flutter/flutter.git
    [  +92 ms] executing: [G:\android\flutter/] git rev-parse --abbrev-ref HEAD
    [  +44 ms] Exit code 0 from: git rev-parse --abbrev-ref HEAD
    [   +1 ms] stable
    [ +109 ms] Artifact Instance of 'AndroidGenSnapshotArtifacts' is not required, skipping update.
    [   +1 ms] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
    [        ] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
    [        ] Artifact Instance of 'FlutterWebSdk' is not required, skipping update.
    [   +5 ms] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
    [        ] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
    [        ] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update.
    [        ] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
    [        ] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
    [        ] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
    [   +1 ms] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
    [ +313 ms] executing: G:\android\sdk\platform-tools\adb.exe devices -l
    [  +64 ms] List of devices attached
               2XJDU17C14006203       device product:WAS-LX1A model:WAS_LX1A device:HWWAS-H transport_id:1
    [  +10 ms] G:\android\sdk\platform-tools\adb.exe -s 2XJDU17C14006203 shell getprop
    [  +95 ms] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
    [   +1 ms] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
    [   +4 ms] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
    [        ] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
    [        ] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update.
    [        ] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
    [        ] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
    [        ] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
    [        ] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
    [ +133 ms] Skipping pub get: version match.
    [  +78 ms] Found plugin connectivity at G:\android\flutter\.pub-cache\hosted\pub.dartlang.org\connectivity-3.0.6\
    [  +11 ms] Found plugin connectivity_for_web at G:\android\flutter\.pub-cache\hosted\pub.dartlang.org\connectivity_for_web-0.4.0\
    [   +3 ms] Found plugin connectivity_macos at G:\android\flutter\.pub-cache\hosted\pub.dartlang.org\connectivity_macos-0.2.0\
    [  +35 ms] Found plugin flutter_radio at G:\android\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_radio-0.1.8\
    [  +37 ms] Found plugin path_provider at G:\android\flutter\.pub-cache\hosted\pub.dartlang.org\path_provider-2.0.2\
    [   +2 ms] Found plugin path_provider_linux at G:\android\flutter\.pub-cache\hosted\pub.dartlang.org\path_provider_linux-2.0.0\
    [   +2 ms] Found plugin path_provider_macos at G:\android\flutter\.pub-cache\hosted\pub.dartlang.org\path_provider_macos-2.0.0\
    [   +3 ms] Found plugin path_provider_windows at G:\android\flutter\.pub-cache\hosted\pub.dartlang.org\path_provider_windows-2.0.1\
    [  +16 ms] Found plugin shared_preferences at G:\android\flutter\.pub-cache\hosted\pub.dartlang.org\shared_preferences-2.0.6\
    [   +3 ms] Found plugin shared_preferences_linux at G:\android\flutter\.pub-cache\hosted\pub.dartlang.org\shared_preferences_linux-2.0.0\
    [   +2 ms] Found plugin shared_preferences_macos at G:\android\flutter\.pub-cache\hosted\pub.dartlang.org\shared_preferences_macos-2.0.0\
    [   +3 ms] Found plugin shared_preferences_web at G:\android\flutter\.pub-cache\hosted\pub.dartlang.org\shared_preferences_web-2.0.0\
    [   +1 ms] Found plugin shared_preferences_windows at G:\android\flutter\.pub-cache\hosted\pub.dartlang.org\shared_preferences_windows-2.0.0\
    [   +7 ms] Found plugin sqflite at G:\android\flutter\.pub-cache\hosted\pub.dartlang.org\sqflite-2.0.0+3\
    [  +13 ms] Found plugin url_launcher at G:\android\flutter\.pub-cache\hosted\pub.dartlang.org\url_launcher-6.0.6\
    [   +2 ms] Found plugin url_launcher_linux at G:\android\flutter\.pub-cache\hosted\pub.dartlang.org\url_launcher_linux-2.0.0\
    [   +1 ms] Found plugin url_launcher_macos at G:\android\flutter\.pub-cache\hosted\pub.dartlang.org\url_launcher_macos-2.0.0\
    [   +3 ms] Found plugin url_launcher_web at G:\android\flutter\.pub-cache\hosted\pub.dartlang.org\url_launcher_web-2.0.1\
    [   +2 ms] Found plugin url_launcher_windows at G:\android\flutter\.pub-cache\hosted\pub.dartlang.org\url_launcher_windows-2.0.0\
    [ +163 ms] Found plugin connectivity at G:\android\flutter\.pub-cache\hosted\pub.dartlang.org\connectivity-3.0.6\
    [   +2 ms] Found plugin connectivity_for_web at G:\android\flutter\.pub-cache\hosted\pub.dartlang.org\connectivity_for_web-0.4.0\
    [   +1 ms] Found plugin connectivity_macos at G:\android\flutter\.pub-cache\hosted\pub.dartlang.org\connectivity_macos-0.2.0\
    [  +16 ms] Found plugin flutter_radio at G:\android\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_radio-0.1.8\
    [  +25 ms] Found plugin path_provider at G:\android\flutter\.pub-cache\hosted\pub.dartlang.org\path_provider-2.0.2\
    [   +2 ms] Found plugin path_provider_linux at G:\android\flutter\.pub-cache\hosted\pub.dartlang.org\path_provider_linux-2.0.0\
    [   +1 ms] Found plugin path_provider_macos at G:\android\flutter\.pub-cache\hosted\pub.dartlang.org\path_provider_macos-2.0.0\
    [   +2 ms] Found plugin path_provider_windows at G:\android\flutter\.pub-cache\hosted\pub.dartlang.org\path_provider_windows-2.0.1\
    [  +14 ms] Found plugin shared_preferences at G:\android\flutter\.pub-cache\hosted\pub.dartlang.org\shared_preferences-2.0.6\
    [   +2 ms] Found plugin shared_preferences_linux at G:\android\flutter\.pub-cache\hosted\pub.dartlang.org\shared_preferences_linux-2.0.0\
    [   +1 ms] Found plugin shared_preferences_macos at G:\android\flutter\.pub-cache\hosted\pub.dartlang.org\shared_preferences_macos-2.0.0\
    [   +2 ms] Found plugin shared_preferences_web at G:\android\flutter\.pub-cache\hosted\pub.dartlang.org\shared_preferences_web-2.0.0\
    [   +1 ms] Found plugin shared_preferences_windows at G:\android\flutter\.pub-cache\hosted\pub.dartlang.org\shared_preferences_windows-2.0.0\
    [   +7 ms] Found plugin sqflite at G:\android\flutter\.pub-cache\hosted\pub.dartlang.org\sqflite-2.0.0+3\
    [   +9 ms] Found plugin url_launcher at G:\android\flutter\.pub-cache\hosted\pub.dartlang.org\url_launcher-6.0.6\
    [   +1 ms] Found plugin url_launcher_linux at G:\android\flutter\.pub-cache\hosted\pub.dartlang.org\url_launcher_linux-2.0.0\
    [   +2 ms] Found plugin url_launcher_macos at G:\android\flutter\.pub-cache\hosted\pub.dartlang.org\url_launcher_macos-2.0.0\
    [   +2 ms] Found plugin url_launcher_web at G:\android\flutter\.pub-cache\hosted\pub.dartlang.org\url_launcher_web-2.0.1\
    [   +1 ms] Found plugin url_launcher_windows at G:\android\flutter\.pub-cache\hosted\pub.dartlang.org\url_launcher_windows-2.0.0\
    [  +28 ms] Generating C:\projects\flutter\example\android\app\src\main\java\io\flutter\plugins\GeneratedPluginRegistrant.java
    [  +89 ms] ro.hardware = hi6250
    [   +1 ms] ro.build.characteristics = default
    [  +69 ms] Initializing file store
    [  +14 ms] Skipping target: gen_localizations
    [   +6 ms] complete
    [   +7 ms] Launching lib\main.dart on WAS LX1A in debug mode...
    [   +8 ms] G:\android\flutter\bin\cache\dart-sdk\bin\dart.exe --disable-dart-dev G:\android\flutter\bin\cache\artifacts\engine\windows-x64\frontend_server.dart.snapshot --sdk-root
    G:\android\flutter\bin\cache\artifacts\engine\common\flutter_patched_sdk/ --incremental --target=flutter --debugger-module-names --experimental-emit-debug-metadata --output-dill
    C:\Users\MAHDIP~1\AppData\Local\Temp\flutter_tools.e97f471f\flutter_tool.3f85af30\app.dill --packages C:\projects\flutter\example\.dart_tool\package_config.json -Ddart.vm.profile=false
    -Ddart.vm.product=false --enable-asserts --track-widget-creation --filesystem-scheme org-dartlang-root --initialize-from-dill build\cache.dill.track.dill
    [  +24 ms] executing: G:\android\sdk\platform-tools\adb.exe -s 2XJDU17C14006203 shell -x logcat -v time -t 1
    [  +20 ms] <- compile package:example/main.dart
    [  +89 ms] --------- beginning of main
               06-12 20:49:38.040 I/TrafficMonitor( 1028): gettimer:interval=2000
    [  +17 ms] executing: G:\android\sdk\platform-tools\adb.exe version
    [  +29 ms] Android Debug Bridge version 1.0.41
               Version 30.0.4-6686687
               Installed as G:\android\sdk\platform-tools\adb.exe
    [  +11 ms] executing: G:\android\sdk\platform-tools\adb.exe start-server
    [  +93 ms] Building APK
    [  +39 ms] Running Gradle task 'assembleDebug'...
    [  +11 ms] Using gradle from C:\projects\flutter\example\android\gradlew.bat.
    [   +2 ms] C:\projects\flutter\example\android\gradlew.bat mode: 33279 rwxrwxrwx.
    [  +16 ms] executing: [C:\projects\flutter\example\android/] C:\projects\flutter\example\android\gradlew.bat -Pverbose=true -Ptarget-platform=android-arm64
    -Ptarget=C:\projects\flutter\example\lib\main.dart -Ptrack-widget-creation=true -Pfilesystem-scheme=org-dartlang-root assembleDebug
    [+1504 ms] Welcome to Gradle 6.5!
    [   +2 ms] Here are the highlights of this release:
    [  +30 ms]  - Experimental file-system watching
    [   +1 ms]  - Improved version ordering
    [   +1 ms]  - New samples
    [   +1 ms] For more details see https://docs.gradle.org/6.5/release-notes.html
    [ +937 ms] FAILURE: Build failed with an exception.
    [   +5 ms] * What went wrong:
    [   +1 ms] Could not open settings generic class cache for settings file 'C:\projects\flutter\example\android\settings.gradle' (C:\Users\Mahdi
    MyName\.gradle\caches\6.5\scripts\bq3hllkgb26p0nrblf5gh8d37\settings6418c6d726070f323dbddda2aadc82ef).
    [   +2 ms] > BUG! exception in phase 'semantic analysis' in source unit '_BuildScript_' Unsupported class file major version 60
    [   +1 ms] * Try:
    [   +1 ms] 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.
    [   +3 ms] * Get more help at https://help.gradle.org
    [   +1 ms] BUILD FAILED in 1s
    [ +615 ms] Running Gradle task 'assembleDebug'... (completed in 3.1s)
    [+15239 ms] Exception: Gradle task assembleDebug failed with exit code 1
    [   +3 ms] "flutter run" took 20,123ms.
    [   +5 ms] 
               #0      throwToolExit (package:flutter_tools/src/base/common.dart:10:3)
               #1      RunCommand.runCommand (package:flutter_tools/src/commands/run.dart:644:9)
               <asynchronous suspension>
               #2      FlutterCommand.verifyThenRunCommand (package:flutter_tools/src/runner/flutter_command.dart:1157:12)
               <asynchronous suspension>
               #3      FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:1009:27)
               <asynchronous suspension>
               #4      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
               <asynchronous suspension>
               #5      AppContext.run (package:flutter_tools/src/base/context.dart:149:12)
               <asynchronous suspension>
               #6      CommandRunner.runCommand (package:args/command_runner.dart:197:13)
               <asynchronous suspension>
               #7      FlutterCommandRunner.runCommand.<anonymous closure> (package:flutter_tools/src/runner/flutter_command_runner.dart:278:9)
               <asynchronous suspension>
               #8      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
               <asynchronous suspension>
               #9      AppContext.run (package:flutter_tools/src/base/context.dart:149:12)
               <asynchronous suspension>
               #10     FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:234:5)
               <asynchronous suspension>
               #11     run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:64:9)
               <asynchronous suspension>
               #12     run.<anonymous closure> (package:flutter_tools/runner.dart:62:12)
               <asynchronous suspension>
               #13     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
               <asynchronous suspension>
               #14     AppContext.run (package:flutter_tools/src/base/context.dart:149:12)
               <asynchronous suspension>
               #15     runInContext (package:flutter_tools/src/context_runner.dart:73:10)
               <asynchronous suspension>
               #16     main (package:flutter_tools/executable.dart:90:3)
               <asynchronous suspension>
               
               
    [ +257 ms] ensureAnalyticsSent: 254ms
    [   +2 ms] Running shutdown hooks
    [   +2 ms] Shutdown hook priority 4
    [   +6 ms] Shutdown hooks complete
    [   +1 ms] exiting with code 1
    

    < code>java版本:

    java version "16.0.1" 2021-04-20
    Java(TM) SE Runtime Environment (build 16.0.1+9-24)
    Java HotSpot(TM) 64-Bit Server VM (build 16.0.1+9-24, mixed mode, sharing)
    

    我该如何解决这个问题?

  • 共有3个答案

    楮法
    2023-03-14

    由于gradle的缓存覆盖,通常会出现此错误。清理缓存

    光盘Android。/gradlew干净

    或者您可以手动清理gradle缓存。转到C:\用户\ganesh.gradle\缓存并从那里删除所有缓存。

    清理缓存后。你可以升级Gradle。屏幕上显示程序运行的图片

    然后运行您的项目。如有必要,只对build.gradle文件截图进行更改

    云瑞
    2023-03-14

    升级导致解决此问题的JDK,我可以构建apkiphone发布应用程序

    赫连智
    2023-03-14

    我也遇到了同样的问题,但是降级jdk解决了这个问题。

    我在计算机中安装了“jdk-16.0.2_windows-x64_bin”,卸载该计算机并安装“jdk-8u301-windows-x64”解决了这个问题。

    安装jdk-8u301-windows-x64

    请注意,安装“jdk-8u301-windows-x64”时需要在oracle中创建帐户。

    完成后,重新启动计算机,然后“运行颤动”,您将很高兴

     类似资料:
    • 我有一个使用Gradle1.10和JDK1.8的1.1.7 spring-boot应用程序。我使用Groovy/Spock测试它有两个依赖项--用Apache Maven 3.1.1和JDK1.8构建JAR。我构建JAR,然后他们将它们复制到/lib目录中。然后我试着用“Gradle clean build”建造。 以下是我的分级文件的一部分:

    • 我正在尝试编译下面的代码Gralde 4.9、Groovy-2.5.2和JDK11,它给出了这个错误,相同的代码在JDK 8中编译。 错误消息 我在这里有github项目:https://github.com/sfgroups/FileUpload

    • 我使用PHP 5.4版本。我得到的问题后,我上传我的Joomla cms文件夹从我的localhost到我的网络托管。 这是密码 我得到这个错误 分析错误:语法错误,在/home/u854215895/public\u html/templates/realestate/html/com\u content/article/default中出现意外的“已定义”(T_字符串)。php在线1 请帮忙.

    • 请帮我解决这个问题。我试图在我的真实设备上运行我的第一个项目,但我得到了这个错误:失败:构建失败,出现异常。 < li >哪里出错:无法打开设置文件“C:\ Users \ Admin \ AndroidStudioProjects \ flutter _ first app \ Android \ settings . gradle”(C:\ Users \ Admin . gradle \ c

    • 基本上,我正在youtube上做注册和登录教程。它使用的是旧版本的PHP,我试图更新代码,但出现以下错误: 分析错误:语法错误,在第23行的C:\Program Files(x86)\EasyPHP-DevServer-14.1VC11\data\localweb\projects\Forum\Forum\core\functions\users.php中出现意外“,” users.php

    • 这个问题是由一个打字错误或一个无法重现的问题引起的。虽然类似的问题可能是这里的主题,但这个问题的解决方式不太可能对未来的读者有所帮助。 当选择为空时,我编辑此代码以显示Mesaje,并且我收到此错误: 这是代码: 第235行是: 我如何解决这个错误?什么是坏的?