简体   繁体   中英

Flutter: Execution failed for task ':cloud_firestore:compileDebugJavaWithJavac'

I have tried everything. I tried moving to android X and still same issue. Only with plugins cloud_firestore and firebase_auth.

Here are my errors and what I have tried so far.

Error:

Launching lib\main.dart on Android SDK built for x86 in debug mode...
Initializing gradle...
Resolving dependencies...
Running Gradle task 'assembleDebug'...
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
C:\flutter\.pub-cache\hosted\pub.dartlang.org\cloud_firestore-0.8.2+1\android\src\main\java\io\flutter\plugins\firebase\cloudfirestore\CloudFirestorePlugin.java:8: error: package android.support.annotation does not exist
import android.support.annotation.NonNull;
                                 ^
C:\flutter\.pub-cache\hosted\pub.dartlang.org\cloud_firestore-0.8.2+1\android\src\main\java\io\flutter\plugins\firebase\cloudfirestore\CloudFirestorePlugin.java:9: error: package android.support.annotation does not exist
import android.support.annotation.Nullable;
                                 ^
C:\flutter\.pub-cache\hosted\pub.dartlang.org\cloud_firestore-0.8.2+1\android\src\main\java\io\flutter\plugins\firebase\cloudfirestore\CloudFirestorePlugin.java:253: error: cannot find symbol
          public void onFailure(@NonNull Exception e) {
                                 ^
  symbol: class NonNull
C:\flutter\.pub-cache\hosted\pub.dartlang.org\cloud_firestore-0.8.2+1\android\src\main\java\io\flutter\plugins\firebase\cloudfirestore\CloudFirestorePlugin.java:274: error: cannot find symbol
                    public Void apply(@NonNull Transaction transaction)
                                       ^
  symbol: class NonNull
C:\flutter\.pub-cache\hosted\pub.dartlang.org\cloud_firestore-0.8.2+1\android\src\main\java\io\flutter\plugins\firebase\cloudfirestore\CloudFirestorePlugin.java:272: error: cannot find symbol
                    @Nullable
                     ^
  symbol: class Nullable
C:\flutter\.pub-cache\hosted\pub.dartlang.org\cloud_firestore-0.8.2+1\android\src\main\java\io\flutter\plugins\firebase\cloudfirestore\CloudFirestorePlugin.java:500: error: cannot find symbol
                    public void onFailure(@NonNull Exception e) {
                                           ^
  symbol: class NonNull
C:\flutter\.pub-cache\hosted\pub.dartlang.org\cloud_firestore-0.8.2+1\android\src\main\java\io\flutter\plugins\firebase\cloudfirestore\CloudFirestorePlugin.java:555: error: cannot find symbol
                    public void onFailure(@NonNull Exception e) {
                                           ^
  symbol: class NonNull
Note: C:\flutter\.pub-cache\hosted\pub.dartlang.org\cloud_firestore-0.8.2+1\android\src\main\java\io\flutter\plugins\firebase\cloudfirestore\CloudFirestorePlugin.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
7 errors

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':cloud_firestore: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 1m 36s
*******************************************************************************************
The Gradle failure may have been because of AndroidX incompatibilities in this Flutter app.
See [THAT GOOGLE URL] for more information on the problem and how to fix it.
*******************************************************************************************
Finished with error: Gradle task assembleDebug failed with exit code 1

Here is the dependencies part of the pubspec.yaml:

dependencies:
  flutter:
    sdk: flutter
  font_awesome_flutter:
  firebase_core: ^0.2.5
  firebase_analytics: ^1.0.4
  firebase_auth: 0.6.2+1
  cloud_firestore: 0.8.2+1
  google_sign_in: ^3.2.4
  rxdart: 0.20.0 
  path_provider: 
  flutter_launcher_icons: 
  fluttertoast: 
  image_picker: 
  photo_view: 
  zoomable_image: 
  camera: 
  flutter_image_compress: 
  google_maps_flutter: 
  flutter_cache_manager: 
  parallax_image: 
  intl: 
  geocoder: 
  location: ^2.3.5
  shared_preferences:  
  percent_indicator:
  rflutter_alert:
  rich_alert: 
  liquid_pull_to_refresh:
  json_annotation:  
  mime:
  firebase_database: 
  scoped_model:
  provider:

Here is my project level build.

buildscript {
  repositories {
    google()
    jcenter()
  }

  dependencies {
    classpath 'com.android.tools.build:gradle:3.2.1'
    classpath 'com.google.gms:google-services:4.2.0'
  }
}

allprojects {
  repositories {
    google()
    jcenter()
  }
}

rootProject.buildDir = '../build'
subprojects {
  project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
  project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
  delete rootProject.buildDir
}

Here is the gradle.properties file:

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

Here is the applevel build.gradle:

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
  localPropertiesFile.withReader('UTF-8') {
    reader - >
      localProperties.load(reader)
  }
}

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
  throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
  flutterVersionCode = '1'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
  flutterVersionName = '1.0'
}



apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
  compileSdkVersion 28

  lintOptions {
    disable 'InvalidPackage'
  }

  defaultConfig {
    // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
    applicationId "com.example.someproject"
    minSdkVersion 21
    targetSdkVersion 28
    versionCode flutterVersionCode.toInteger()
    versionName flutterVersionName
    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    //testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    multiDexEnabled true
  }

  buildTypes {
    release {
      // TODO: Add your own signing config for the release build.
      // Signing with the debug keys for now, so `flutter run --release` works.
      signingConfig signingConfigs.debug
    }
  }
}

flutter {
  source '../..'
}

dependencies {
  testImplementation 'junit:junit:4.12'
  androidTestImplementation 'androidx.test:runner:1.1.1'
  androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
  //implementation 'androidx.annotation:annotation:1.1.0'
  implementation 'androidx.appcompat:appcompat:1.0.0'
  implementation 'com.google.firebase:firebase-core:16.0.9'
  //implementation 'com.android.support:support-annotations'

  /* implementation 'com.google.firebase:firebase-core:16.0.1'
  testImplementation 'junit:junit:4.12'
  androidTestImplementation 'com.android.support.test:runner:1.0.2'
  androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
  compile 'com.android.support:multidex:1.0.3' */

}

apply plugin: 'com.google.gms.google-services'

one of my project use firebase and its update to androidX, i dont know why in your app/build.gradle dependenies you hace so many lines. this its my.

dependencies {
   testImplementation 'junit:junit:4.12'
   androidTestImplementation 'androidx.test:runner:1.1.1'
   androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
}
# this line its for some bug when use firebase, local_auth and fire_auth at the same time 

configurations {
  all*.exclude group: 'com.google.guava', module: 'listenablefuture'
}

apply plugin: 'com.google.gms.google-services'

Flutter & AndroidX incompatibility How to set a dependency manually

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM