任务“:cloud_firestore:compileDebugJavaWithJavac”执行失败

Posted

技术标签:

【中文标题】任务“:cloud_firestore:compileDebugJavaWithJavac”执行失败【英文标题】:Execution failed for task ':cloud_firestore:compileDebugJavaWithJavac' 【发布时间】:2020-06-26 17:18:30 【问题描述】:

我很抱歉提出已经提出的问题,原因是我没有得到它, 谁能帮我解决这个问题

这是我得到的例外 任务“:cloud_firestore:compileDebugJavaWithJavac”执行失败。 并且应用无法运行模拟器

D:\flutter\.pub-cache\hosted\pub.dartlang.org\cloud_firestore-0.8.2+3\android\src\main\java\io\flutter\plugins\firebase\cloudfirestore\CloudFirestorePlugin.java:274: error: cannot find symbole\CloudFirestorePlugin.java:8: error: package android.support.annotation does not exist
import android.support.annotation.NonNull;
                                 ^
D:\flutter\.pub-cache\hosted\pub.dartlang.org\cloud_firestore-0.8.2+3\android\src\main\java\io\flutter\plugins\firebase\cloudfirestore\CloudFirestorePlugin.java:272: error: cannot find symbole\CloudFirestorePlugin.java:9: error: package android.support.annotation does not exist
import android.support.annotation.Nullable;
                                 ^
D:\flutter\.pub-cache\hosted\pub.dartlang.org\cloud_firestore-0.8.2+3\android\src\main\java\io\flutter\plugins\firebase\cloudfirestore\CloudFirestorePlugin.java:503: error: cannot find symbole\CloudFirestorePlugin.java:253: error: cannot find symbol
          public void onFailure(@NonNull Exception e) 
                                 ^
  symbol: class NonNull                                                                                                              e\CloudFirestorePlugin.java:558: error: cannot find symbol
D:\flutter\.pub-cache\hosted\pub.dartlang.org\cloud_firestore-0.8.2+3\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
D:\flutter\.pub-cache\hosted\pub.dartlang.org\cloud_firestore-0.8.2+3\android\src\main\java\io\flutter\plugins\firebase\cloudfirestore\CloudFirestorePlugin.java:272: error: cannot find symbol
                    @Nullable
                     ^
  symbol: class Nullable
D:\flutter\.pub-cache\hosted\pub.dartlang.org\cloud_firestore-0.8.2+3\android\src\main\java\io\flutter\plugins\firebase\cloudfirestore\CloudFirestorePlugin.java:503: error: cannot find symbol
                    public void onFailure(@NonNull Exception e)                                                                      full insights.
                                           ^
  symbol: class NonNull
D:\flutter\.pub-cache\hosted\pub.dartlang.org\cloud_firestore-0.8.2+3\android\src\main\java\io\flutter\plugins\firebase\cloudfirestore\CloudFirestorePlugin.java:558: error: cannot find symbol
                    public void onFailure(@NonNull Exception e) 
                                           ^
  symbol: class NonNull                                    
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.


BUILD FAILED in 5s
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... Done                         6.3s
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.

下面是 app/build.gradle 文件中的依赖和插件


apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
apply plugin: 'com.google.gms.google-services'

android 
    compileSdkVersion 29

    sourceSets 
        main.java.srcDirs += 'src/main/kotlin'
    

    lintOptions 
        disable 'InvalidPackage'
    

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

    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 
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.2.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'

    implementation 'com.google.firebase:firebase-analytics:17.2.2'


下面是 andriod/build.gradle 中的依赖项

buildscript 
    ext.kotlin_version = '1.3.50'
    repositories 
        google()
        jcenter()
    

    dependencies 
        classpath 'com.android.tools.build:gradle:3.6.1'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.google.gms:google-services:4.3.3'
    


allprojects 
    repositories 
        google()
        jcenter()
    




pubspec.yaml 中的依赖项

dependencies:
  flutter:
    sdk: flutter
  carousel_pro: ^1.0.0
  firebase_auth: ^0.6.6 
  cloud_firestore: any
  google_sign_in: ^4.1.4
  shared_preferences: ^0.5.6+2
  fluttertoast: ^3.1.3
  provider: 3.0.0
  flutter_svg: ^0.17.3+1

【问题讨论】:

从任何更改为 cloud_firestore:^0.13.4+2 @vinny 我尝试了你的建议,但我得到了一个新错误,我在下面提到了@jose Praveen 因为 cloud_firestore >=0.13.3 依赖于 firebase_core ^0.4.4 而 firebase_auth 0.6.6 依赖于 firebase_core ^0.2.5+1,所以 cloud_firestore >=0.13.3 与 firebase_auth 0.6.6 不兼容.并且由于没有任何版本的 firebase_auth 匹配 >0.6.6 =0.13.3 与 firebase_auth ^0.6.6 不兼容。所以,因为smile同时依赖firebase_auth ^0.6.6和cloud_firestore ^0.13.4+2,所以版本解析失败。 【参考方案1】:

您似乎缺少 firebase_core 插件,这是使用 Firebase Core API 的必备包。

查看this documentation 了解有关在 Flutter 中使用 Firebase 的更多信息。

另一个可能的原因可能是您的 cloud_firestore 插件的版本,它可能与其他依赖项冲突。使用最新版本的软件包(例如 cloud_firestore 3.1.0)并在您的 app/build.gradle 上,将 minSdkVersion 16 更新为 minSdkVersion 23,如 this SO post 中所述。

【讨论】:

以上是关于任务“:cloud_firestore:compileDebugJavaWithJavac”执行失败的主要内容,如果未能解决你的问题,请参考以下文章

任务计划程序打开软件的原理

CELERY 定时任务

“异步任务然后等待任务”与“任务然后返回任务”[重复]

宏任务和微任务的执行顺序

宏任务和微任务

20230515学习笔记——js中的同步任务与异步任务,宏任务与微任务