Home > Software engineering >  failed for task ':app:compileDebugJavaWithJavac'
failed for task ':app:compileDebugJavaWithJavac'

Time:05-13

first :I modify the value of the global minSdkVersion variable from the source to 19 so that all projects (old and new) will take it .

second :I added the flutter firebase plug-ins and flutter run successful

final :when I see the seedebug console it go wrong in vscode.I don't know how to solve it

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)

this flutter doctor -v app: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

my 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
    }

i add this in app/build.gradle but It didn't work

 buildToolVersion "23.0.1"

java_home was set up before I ues vscode to set up this project

the environment variables java_home

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

CodePudding user response:

Did you have 1.multidex initialization in app/build.gradle like below

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

2.Check below or add in android/gradle.properties

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

CodePudding user response:

Upgrade your buildToolsVersion in build.gradle to "23.0.1" as follows:

compileSdkVersion 23
buildToolsVersion "23.0.1".
  • Related