【发布时间】:2019-08-13 01:53:01
【问题描述】:
我是 Flutter 框架的新手。我正在尝试在 Flutter 中安装 Cloud Firestore,但遇到了问题。以下是我的代码和 gradle 文件: Android/build.gradlew:
buildscript {
// ext.kotlin_version = '1.2.31'
repositories {
google()
jcenter()
maven {
url "https://maven.google.com"
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.google.gms:google-services:3.2.0'
}
}
allprojects {
repositories {
google()
jcenter()
maven {
url "https://maven.google.com"
}
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
App/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.barcode_app"
minSdkVersion 16
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "android.support.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 {
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'
在运行 flutter run -v 或在 android 中构建后,我得到了错误: “错误:未找到 ID 为 'com.google.gms:google-services' 的插件。” enter image description here
我尝试了stackoverflow和github上几乎所有可用的解决方案,但问题仍然存在。
【问题讨论】:
-
转到您的 Android Studio SDK 管理器并在 SDK 工具中检查是否安装了 Google Play Services 和 Google Repository。
-
您好,欢迎来到 StackOverflow,如果您能引用您已经尝试过的其他解决方案或对其进行解释,那将非常有用。那么您将不会收到重复的答案,并且可能的回答者会知道要避免什么。
-
@Ryosuke 是的,我已经安装了这两个。
标签: android flutter flutter-dependencies