Dear Flutter community,
I am banging my head on a seemingly simple task.
I want to add firebase
authentication to my app. It worked on iOS
but as I tried to implement it for android
, I systematically get the error :
Launching lib/main.dart on Android SDK built for x86 in debug mode... Initializing gradle... Resolving dependencies... Running 'gradlew assembleDebug'... Configuration 'compile' in project ':app' is deprecated. Use 'implementation' instead. registerResGeneratingTask is deprecated, use registerGeneratedFolders(FileCollection) registerResGeneratingTask is deprecated, use registerGeneratedFolders(FileCollection) registerResGeneratingTask is deprecated, use registerGeneratedFolders(FileCollection) Configuration 'compile' in project ':google_sign_in' is deprecated. Use 'implementation' instead.
FAILURE: Build failed with an exception.
What went wrong: Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Get more help at https://help.gradle.org
BUILD FAILED in 34s Finished with error: Gradle build failed: 1
I reproduced the error using 'flutter create'
then adding Firebase
capabilities following the codelab
https://codelabs.developers.google.com/codelabs/flutter-firebase/#4
Here is the only modification to 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
general 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'
here is the flutter doctor output :
[✓] Flutter (on Mac OS X 10.13.2 17C88, locale fr-BE, channel master) • Flutter at /Users/sergebesnard/flutter • Framework revision 4d2c2aaaa1 (6 days ago), 2017-12-27 07:30:31 -0800 • Engine revision 7c126001d8 • Tools Dart version 1.25.0-dev.11.0 • Engine Dart version 2.0.0-edge.9e8a3e2d31621c1bdf6139d068e7898a2ac2ab5a
[✓] Android toolchain - develop for Android devices (Android SDK 27.0.2) • Android SDK at /Users/sergebesnard/Library/Android/sdk • Android NDK location not configured (optional; useful for native profiling support) • Platform android-27, build-tools 27.0.2 • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-915-b08)
[✓] iOS toolchain - develop for iOS devices (Xcode 9.2) • Xcode at /Applications/Xcode.app/Contents/Developer • Xcode 9.2, Build version 9C40b • ios-deploy 1.9.2 • CocoaPods version 1.3.1
[✓] Android Studio (version 3.0) • Android Studio at /Applications/Android Studio.app/Contents • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-915-b08)
[✓] IntelliJ IDEA Community Edition (version 2017.2.5) • Flutter plugin version 18.0 • Dart plugin version 172.4155.35
[✓] Connected devices • Android SDK built for x86 • emulator-5554 • android-x86 • Android 8.0.0 (API 26) (emulator)
I am obviously new to Android
development, and would prefer not to have to become expert to get the tutorial working. Every solution I found required tinkering with the .gradle files
and only apply to react-native
.
Thank you for your help !