亲爱的Flutter社区,
我正在敲打一个看似简单的任务 . 我想在我的应用中添加 firebase
身份验证 . 它工作在 iOS
但是当我试图为 android
实现它时,我系统地得到错误:
在调试模式下为x86构建的Android SDK上启动lib / main.dart ...初始化gradle ...解决依赖关系...运行'gradlew assembleDebug'...项目':app'中的配置'compile'已弃用 . 请改用“实施” . 不推荐使用registerResGeneratingTask,不推荐使用registerGeneratedFolders(FileCollection)registerResGeneratingTask,不推荐使用registerGeneratedFolders(FileCollection)registerResGeneratingTask,使用registerGeneratedFolders(FileCollection)不赞成在项目':google_sign_in'中配置'compile' . 请改用“实施” . FAILURE:构建因异常而失败 . 出了什么问题:任务执行失败':app:transformDexArchiveWithExternalLibsDexMergerForDebug' . java.lang.RuntimeException:java.lang.RuntimeException:com.android.builder.dexing.DexArchiveMergerException:无法合并dex尝试:使用--stacktrace选项运行以获取堆栈跟踪 . 使用--info或--debug选项运行以获取更多日志输出 . 在https://help.gradle.org获取更多帮助 . 在34s内 Build 失败完成时出错:Gradle build failed:1
我使用 'flutter create'
重现了错误,然后在 codelab
https://codelabs.developers.google.com/codelabs/flutter-firebase/#4之后添加 Firebase
功能
这是对 pubspec.yaml
的唯一修改
dependencies:
flutter:
sdk: flutter
google_sign_in: 0.3.1 # ONLY MODIFICATION
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.0
一般 build.gradle
:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.google.gms:google-services:3.1.0' #ONLY MODIF
}
}
allprojects {
repositories {
google()
jcenter()
}
}
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.withInputStream { stream ->
localProperties.load(stream)
}
}
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 26
buildToolsVersion '26.0.3'
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.mycompany.test"
minSdkVersion 16
targetSdkVersion 26
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 {
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'
这是颤动的医生输出:
[✓] Flutter(在Mac OS X 10.13.2 17C88上,语言环境fr-BE,通道主站)•在/ Users / sergebesnard / flutter处颤动•Framework revision 4d2c2aaaa1(6天前),2017-12-27 07:30 :31 -0800•引擎修订版7c126001d8•工具Dart版本1.25.0-dev.11.0•Engine Dart版本2.0.0-edge.9e8a3e2d31621c1bdf6139d068e7898a2ac2ab5a [✓] Android工具链 - 为Android设备开发(Android SDK 27.0.2)•Android SDK at / Users / sergebesnard / Library / Android / sdk•Android NDK位置未配置(可选;对本机分析支持很有用)•平台android-27,构建工具27.0.2•Java二进制文件位于:/ Applications / Android Studio.app / Contents / jre / jdk / Contents / Home / bin / java•Java版OpenJDK运行时环境(版本1.8.0_152-release-915-b08)[✓] iOS工具链 - 为iOS设备开发(Xcode 9.2)•Xcode at / Applications / Xcode.app / Contents / Developer•Xcode 9.2,Build version 9C40b•ios-deploy 1.9.2•CocoaPods 1.3.1版[✓] Android Studio(versi) 3.0)•Android Studio at / Applications / Android Studio.app/Contents•Java版OpenJDK运行时环境(版本1.8.0_152-release-915-b08)[✓] IntelliJ IDEA社区版(2017.2.5版)•Flutter插件版本18.0•Dart插件版本172.4155.35 [✓]已连接的设备•为x86构建的Android SDK•emulator-5554•android-x86•Android 8.0.0(API 26)(模拟器)
我显然是 Android
开发的新手,并且宁愿不必成为专家来使教程工作 . 我找到的每个解决方案都需要修补 .gradle files
并且仅适用于 react-native
.
谢谢您的帮助 !
4 回答
解决:插件和框架之间使用的不兼容版本 . Google SignIn插件0.4.0及更高版本应与最新版本中使用
flutter create
创建的新项目一起使用 .codelab
不再有效,应予以更新 .我也有同样的问题,我读到你必须在app \ build.gradle defaultConfig部分中包含multiDexEnabled true . 这对我有用 .
这里的问题可能是您依赖的插件具有冲突的gradle依赖性 .
这里的答案https://stackoverflow.com/a/49901209/90918提供了如何通过查找冲突的依赖关系并覆盖它们来解决此问题的描述 .
引用原始答案:
此错误表示您的某些依赖项使用不同版本的Google Play服务 .
您必须降级/升级插件才能统一使用的版本