使用真实设备在 flutter 中调试第一个应用程序时出错

Error while debugging first app in flutter using a real device

我在 Ubuntu 20.04 中使用没有 Android 工作室的 VS 代码。虽然 运行 第一个在真实设备中以调试模式运行的应用程序产生了下面给出的错误。我也尝试更改我的 JDK 版本,但没有成功。

Launching lib/main.dart on Nokia 6 1 Plus in debug mode...

FAILURE: Build failed with an exception.                                

* What went wrong:                                                      
Could not initialize class org.codehaus.groovy.runtime.InvokerHelper    

* 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 12s                                                     
Running Gradle task 'assembleDebug'...                                  
Running Gradle task 'assembleDebug'... Done                        18.3s
Exception: Gradle task assembleDebug failed with exit code 1

请提出解决方案!

您的 gradle 同步由于某种原因失败。 这样做

  1. 文件 > 打开
  2. 导航到您的项目
  3. 您会看到一个 android 文件夹,在新的 window
  4. 中将其作为项目打开
  5. 检查 gradle 同步问题并解决这些问题