android - 评估项目“:cloud_firestore”时出现问题
问题描述
我和我的团队成员一起开发了一个 Flutter 项目。我最近从 github 拉出来,它给出了这个错误。但是,我的朋友没有同样的问题,也没有从相同的代码中得到错误。
我得到那个错误
FAILURE: Build failed with an exception.
Where:
Build file 'C:\development\flutter\.pub-cache\hosted\pub.dartlang.org\cloud_firestore-0.16.0\android\build.gradle' line: 41
What went wrong:
A problem occurred evaluating project ':cloud_firestore'.
build_2yq8w8slntfd1pcrdfbqqhulb$_run_closure2$_closure4
或者那个
FAILURE: Build failed with an exception.
* Where:
Build file 'C:\development\flutter\.pub-cache\hosted\pub.dartlang.org\cloud_firestore-0.16.0\android\build.gradle' line: 41
* What went wrong:
A problem occurred evaluating project ':cloud_firestore'.
> Incompatible magic value 0 in class file build_$_run_closure2$_closure4
build.gradle 中的代码行如下
39 android {
40 compileSdkVersion 29
41 compileOptions {
42 sourceCompatibility JavaVersion.VERSION_1_8
43 targetCompatibility JavaVersion.VERSION_1_8
44 }
解决方案是什么?我感谢您的帮助。
整个 build.gradle
group 'io.flutter.plugins.firebase.cloudfirestore'
version '1.0-SNAPSHOT'
buildscript {
repositories {
google()
jcenter()
mavenLocal()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.4'
}
}
allprojects {
repositories {
google()
jcenter()
mavenLocal()
}
}
apply plugin: 'com.android.library'
def firebaseCoreProject = findProject(':firebase_core')
if (firebaseCoreProject == null) {
throw new GradleException('Could not find the firebase_core FlutterFire plugin, have you added it as a dependency in your pubspec?')
} else if (!firebaseCoreProject.properties['FirebaseSDKVersion']) {
throw new GradleException('A newer version of the firebase_core FlutterFire plugin is required, please update your firebase_core pubspec dependency.')
}
def getRootProjectExtOrCoreProperty(name, firebaseCoreProject) {
if (!rootProject.ext.has('FlutterFire')) return firebaseCoreProject.properties[name]
if (!rootProject.ext.get('FlutterFire')[name]) return firebaseCoreProject.properties[name]
return rootProject.ext.get('FlutterFire').get(name)
}
android {
compileSdkVersion 29
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
minSdkVersion 16
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
lintOptions {
disable 'InvalidPackage'
}
dependencies {
api firebaseCoreProject
implementation platform("com.google.firebase:firebase-bom:${getRootProjectExtOrCoreProperty("FirebaseSDKVersion", firebaseCoreProject)}")
implementation 'com.google.firebase:firebase-firestore'
implementation 'androidx.annotation:annotation:1.1.0'
}
}
apply from: file("./user-agent.gradle")
更新
我刚刚删除了以下目录并且它有效
C:\Users\USER_NAME\.gradle\caches
C:\Users\USER_NAME\.android\build-cache
C:\Users\USER_NAME\.android\cache
解决方案
对于所有面临此问题的人来说,这里是修复
在 android/gradle/wrapper/gradle-wrapper.properties 中:
distributionUrl=https://services.gradle.org/distributions/gradle-5.4.1-all.zip
推荐阅读
- excel - 如何使用 Dir 和 Mkdir 并参考 Sharepoint?
- sql - [Microsoft][ODBC Driver 13 for SQL Server]连接到 Azure SQL 数据仓库时查询超时
- javascript - 使用 Javascript 从另一个文件中获取 HTML
- python - ModuleNotFoundError:没有名为“utils.datasets”的模块
- c++ - 在双菱形中到达远处基类的字段或方法的方法是什么?
- python - 基于匹配列的映射值 - Python
- node.js - 未处理的承诺拒绝警告heroku部署
- node.js - 当同时使用 GraphQL 时,Nodejs 和 Express 在 MERN 堆栈 Web 应用程序中的作用是什么?
- pip - 子进程的包依赖
- ios - Mapbox:注释更改时刷新annotationView