在尝试在Android Studio中运行我的Flutter项目时,我在使用flutter包进行firebase Cloud 消息传递时遇到以下错误:
在调试模式下在ZUK Z2132上启动lib \ main.dart ...初始化gradle ...解决依赖关系... *运行Gradle时出错:退出代码1:C:\ Users \ Ada3 \ AndroidStudioProjects \ fast_pos_tester \ android \ gradlew .bat app:properties:项目':app'中的配置'compile'已弃用 . 请改用“实施” . FAILURE:构建因异常而失败 .
*地点:
完成错误:请检查android /文件夹中的Gradle项目设置 .
构建文件'C:\ Users \ Ada3 \ AndroidStudioProjects \ fast_pos_tester \ android \ build.gradle'
行:25 *出了什么问题:
评估根项目'android'时出现问题 .
配置项目':app'时出现问题 .
无法解析配置':app:debugCompileClasspath'的所有依赖项 .
多个项目变体:firebase_messaging匹配使用者属性:
- 配置':firebase_messaging:debugApiElements'变种android-aidl:
- 发现artifactType'android-aidl'但不是必需的 .
这是gradle代码(在app文件夹中)
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.")
}
apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion 27
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.witbybit.fastpostester"
minSdkVersion 16
targetSdkVersion 27
versionCode 1
versionName "1.0"
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 {
implementation 'com.google.firebase:firebase-core:15.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}
apply plugin: 'com.google.gms.google-services'
这是pubspec.yaml
name: fast_pos_tester
description: A new Flutter application.
dependencies:
flutter:
sdk: flutter
firebase_messaging: "^1.0.0"
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.0
dev_dependencies:
flutter_test:
sdk: flutter
# For information on the generic Dart part of this file, see the
# following page: https://www.dartlang.org/tools/pub/pubspec
# The following section is specific to Flutter.
flutter:
# The following line ensures that the Material Icons font is
# included with your application, so that you can use the icons in
# the material Icons class.
uses-material-design: true
# To add assets to your application, add an assets section, like this:
# assets:
# - images/a_dot_burr.jpeg
# - images/a_dot_ham.jpeg
# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.io/assets-and-images/#resolution-aware.
# For details regarding adding assets from package dependencies, see
# https://flutter.io/assets-and-images/#from-packages
# To add custom fonts to your application, add a fonts section here,
# in this "flutter" section. Each entry in this list should have a
# "family" key with the font family name, and a "fonts" key with a
# list giving the asset and other descriptors for the font. For
# example:
# fonts:
# - family: Schyler
# fonts:
# - asset: fonts/Schyler-Regular.ttf
# - asset: fonts/Schyler-Italic.ttf
# style: italic
# - family: Trajan Pro
# fonts:
# - asset: fonts/TrajanPro.ttf
# - asset: fonts/TrajanPro_Bold.ttf
# weight: 700
#
# For details regarding fonts from package dependencies,
# see https://flutter.io/custom-fonts/#from-packages
我无法弄清楚发生了什么 .
1 回答
请检查您是否正确编写了库依赖项/ api键
你需要发布你的flutter pubspec.yaml和gradle代码,这样我们可以告诉你那里有什么问题:)