[英]Flutter app is not compiled with cloud_firestore plugin
I already added google-service.json
under android/app
.我已经在
android/app
下添加了google-service.json
。 But I've got error message when try build app.但是我在尝试构建应用程序时收到错误消息。
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':cloud_firestore:processDebugGoogleServices'.
> Please fix the version conflict either by updating the version of the google-services plugin (information about the latest version is available at https://bintray.com/android/android-tools/com.google.gms.google-services/) or updating the version of com.google.android.gms to 11.4.2.
* 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 1s
Finished with error: Gradle task assembleDebug failed with exit code 1
I tried flutter clean
-> flutter packages get
but it can't solve my problem.我试过
flutter clean
-> flutter packages get
但它不能解决我的问题。
version: 1.0.0+1
environment:
sdk: ">=2.0.0-dev.68.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^0.1.2
http: ^0.11.3+17
json_annotation: ^0.2.3
cloud_firestore: ^0.8.0
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
implementation 'com.android.support:multidex:1.0.3'
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'
}
apply plugin: 'com.google.gms.google-services'
I didn't add implementation 'com.google.firebase:firebase-core:16.0.3'
and implementation 'com.google.firebase:firebase-database:16.0.2'
because, I follow the codelab guide.( https://codelabs.developers.google.com/codelabs/flutter-firebase/#5 )我没有添加
implementation 'com.google.firebase:firebase-core:16.0.3'
和implementation 'com.google.firebase:firebase-database:16.0.2'
因为,我遵循了代码实验室指南。( https:// /codelabs.developers.google.com/codelabs/flutter-firebase/#5 )
This line specifies version 3.2.1 of the plugin (do not use version 3.3.0 or 3.3.1 at this point).
此行指定插件的版本3.2.1 (此时不要使用版本 3.3.0 或 3.3.1)。 For more information see the Add the SDK section of the Add Firebase to Your Android Project documentation (but don't follow those instructions as they are different from the Flutter instructions) .
有关更多信息,请参阅将 Firebase 添加到您的 Android 项目文档的添加 SDK 部分(但不要遵循这些说明,因为它们与 Flutter 说明不同) 。
buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:3.2.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:3.2.1'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
Update更新
I also tried with update gradle version to 4.6.我还尝试将 gradle 版本更新到 4.6。 File -> Project Structure -> Project
文件->项目结构->项目
dependencies {
classpath 'com.android.tools.build:gradle:3.2.0'
classpath 'com.google.gms:google-services:4.1.0'
}
But still error occurs.但仍然发生错误。
If I tried gradle sync,如果我尝试 gradle 同步,
Unable to resolve dependency for ':app@dynamicProfile/compileClasspath': Could not resolve project :cloud_firestore.
Unable to resolve dependency for ':app@dynamicProfile/compileClasspath': Could not resolve project :firebase_core.
And tried build flutter binary,并尝试构建颤振二进制文件,
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':cloud_firestore:processDebugGoogleServices'.
> File google-services.json is missing. The Google Services Plugin cannot function without it.
Searched Location:
/Users/kenny/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-0.8.0/android/src/nullnull/debug/google-services.json
/Users/kenny/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-0.8.0/android/src/debug/nullnull/google-services.json
/Users/kenny/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-0.8.0/android/src/nullnull/google-services.json
/Users/kenny/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-0.8.0/android/src/debug/google-services.json
/Users/kenny/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-0.8.0/android/src/nullnullDebug/google-services.json
/Users/kenny/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-0.8.0/android/google-services.json
* 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 9s
Finished with error: Gradle task assembleDebug failed with exit code 1
{
"project_info": {
"project_number": "1234566",
"firebase_url": "https://XXXXXX.firebaseio.com",
"project_id": "XXXXXX",
"storage_bucket": "XXXXXX.appspot.com"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:123456:android:1234567890",
"android_client_info": {
"package_name": "com.package.name"
}
},
"oauth_client": [
{
"client_id": "client_id.apps.googleusercontent.com",
"client_type": 3
}
],
"api_key": [
{
"current_key": "client_key"
}
],
"services": {
"analytics_service": {
"status": 1
},
"appinvite_service": {
"status": 1,
"other_platform_oauth_client": []
},
"ads_service": {
"status": 2
}
}
}
],
"configuration_version": "1"
}
Use 0.7.4
version instead of 0.8.0
for cloud_firestore
.对于
cloud_firestore
使用0.7.4
版本而不是0.8.0
。
Change gradle dependencies更改 gradle 依赖项
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
...
}
Use multiDex使用 multiDex
This works for me.这对我有用。
Flutterfire has recently rolled out Dart-only initialization which should help prevent setup issues similar to this from happening. Flutterfire 最近推出了 Dart-only 初始化,这应该有助于防止发生类似的设置问题。 Follow this guide laid out on their docs to migrate from manual platform-specific setups to Dart-only initialization.
按照他们的文档中列出的本指南从手动平台特定设置迁移到仅 Dart 初始化。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.