任务 ':app:compileDebugJavaWithJavac' 失败

failed for task ':app:compileDebugJavaWithJavac'

首先:我把源码中的全局minSdkVersion变量的值修改为19,这样所有的项目(新旧)都会取。

第二个:我添加了flutter firebase插件和flutter运行成功

final : 当我看到 seedebug 控制台时出错 vscode.I 不知道如何解决

D:\flutter_application_3_vs\android\app\src\main\java\io\flutter\app\FlutterMultiDexApplication.java:12: ����: �����androidx.multidex������
import androidx.multidex.MultiDex;
                        ^
D:\flutter_application_3_vs\android\app\src\main\java\io\flutter\app\FlutterMultiDexApplication.java:22: ����: �Ҳ�������
    MultiDex.install(this);
    ^
  ����:   ���� MultiDex
  �: �� FlutterMultiDexApplication
2 ������

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

* 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 7s
Exception: Gradle task assembleDebug failed with exit code 1
Exited (sigterm)

本扑博士-vapp:compileDebugJavaWithJavac

[√] Flutter (Channel stable, 3.0.0, on Microsoft Windows [版本 10.0.19044.1645], locale zh-Hans-HK)
    • Flutter version 3.0.0 at D:\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision ee4e09cce0 (2 days ago), 2022-05-09 16:45:18 -0700
    • Engine revision d1b9a6938a
    • Dart version 2.17.0
    • DevTools version 2.12.2
    • Pub download mirror https://pub.flutter-io.cn
    • Flutter download mirror https://storage.flutter-io.cn

[√] Android toolchain - develop for Android devices (Android SDK version 32.0.0)
    • Android SDK at D:\SDK
    • Platform android-32, build-tools 32.0.0
    • ANDROID_HOME = D:\SDK
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 11.0.12+7-b1504.28-7817840)
    • All Android licenses accepted.

[X] Chrome - develop for the web (Cannot find Chrome executable at .\Google\Chrome\Application\chrome.exe)
    ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.

[X] Visual Studio - develop for Windows
    X Visual Studio not installed; this is necessary for Windows development.
      Download at https://visualstudio.microsoft.com/downloads/.
      Please install the "Desktop development with C++" workload, including all of its default components

[√] Android Studio (version 2021.2)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.12+7-b1504.28-7817840)

[√] Connected device (3 available)
    • Android SDK built for x86 64 (mobile) • emulator-5554 • android-x64    • Android 12 (API 31) (emulator)
    • Windows (desktop)                     • windows       • windows-x64    • Microsoft Windows [版本 10.0.19044.1645]
    • Edge (web)                            • edge          • web-javascript • Microsoft Edge 101.0.1210.39

[√] HTTP Host Availability
    • All required HTTP hosts are available

我的app/build.gradle

android {
    compileSdkVersion flutter.compileSdkVersion

  defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.example.flutter_application_3_vs"
        minSdkVersion flutter.minSdkVersion
        targetSdkVersion flutter.targetSdkVersion
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
    }

我在 app/build.gradle 中添加了这个,但没有用

 buildToolVersion "23.0.1"

java_home是在我使用vscode设置这个项目之前设置的

环境变量java_home

JAVA_HOME17:
D:\JDK\java\jdk-17.0.1

将 build.gradle 中的 buildToolsVersion 升级为“23.0.1”,如下所示:

compileSdkVersion 23
buildToolsVersion "23.0.1".

你有没有 1.multidex 在 app/build.gradle 中初始化,如下所示

defaultConfig {
  //add this line
    multiDexEnabled true
}
dependencies {
//add these lines
def multidex_version = "2.0.1"
implementation "androidx.multidex:multidex:$multidex_version"
}

2.Check 下方或添加 android/gradle.properties

org.gradle.jvmargs=-Xmx1536M
android.enableR8=true
android.useAndroidX=true
android.enableJetifier=true