Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter error: Execution failed for task ':app:compileDebugJavaWithJavac'

Tags:

flutter

I try run on android and return this error.

I Aredy tried:

gradle.properties:

android.useAndroidX=true android.enableJetifier=true

build.gradle:

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" multiDexEnabled true

my pubspec.yaml:

flutter_facebook_login: ^3.0.0 firebase_database: ^3.1.0 firebase_auth: ^0.15.0+1 cloud_firestore: ^0.12.11 url_launcher: ^5.2.7 google_maps_flutter: ^0.5.21+12 image_picker: ^0.6.2+1 firebase_storage: ^3.0.8 intl: ^0.16.0

  • 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 35s The built failed likely due to AndroidX incompatibilities in a plugin. The tool is about to try using Jetfier to solve the incompatibility. Building plugin cloud_firestore... The plugin cloud_firestore could not be built due to the issue above.


SOLUTION:

When you created the new project, did you select "androidX"? And are those versions the latest versions? (meaning, androidX compatible/requiring). if not sure, create a new project and make sure to select androidX, and change the sdk settings to 23/29 as above.

like image 404
Robson Dona Avatar asked Dec 04 '19 13:12

Robson Dona


1 Answers

Edit: Solution was a combination of creating a new project with AndroidX selected and add the proper SDK versions to the gradle file. Possibly with using correct dependency versions.

To migrate to AndroidX, you need to set the SDK versions to 21 or higher. I recommend 23 because that removes some other issues as well.

compileSdkVersion 29

lintOptions {
    disable 'InvalidPackage'
}

defaultConfig {
    // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
    applicationId "com.example"
    minSdkVersion 23
    targetSdkVersion 29
    versionCode flutterVersionCode.toInteger()
    versionName flutterVersionName
    // testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
like image 110
Jonas357 Avatar answered Oct 16 '22 17:10

Jonas357