If I add the firebase_core to my flutter project, it doesn't run on Android. In iOS it's ok.
I have this gradle error.
Launching lib/main.dart on Android SDK built for x86 in debug mode... Initializing gradle... Resolving dependencies... Running Gradle task 'assembleDebug'... registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection) registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection) registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection) registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection) registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection) FAILURE: Build failed with an exception. * What went wrong: Could not determine the dependencies of task ':firebase_core:compileDebugAidl'. > Could not resolve all task dependencies for configuration ':firebase_core:debugCompileClasspath'. > Could not find com.google.firebase:firebase-core:. Required by: project :firebase_core
- pubspec:
dependencies: date_format: ^1.0.6 flutter: sdk: flutter url_launcher: ^5.0.2 webview_flutter: ^0.3.5+3 #path: ./../webview_flutter shared_preferences: ^0.5.1+2 local_auth: ^0.4.0+1 http: ^0.12.0+1 xml: ^3.3.1 #flutter_auth_buttons: ^0.3.1 flutter_masked_text: ^0.8.0 path_provider: ^0.5.0+1 base32: ^1.0.1 #json_serializable: ^2.0.3 get_it: ^1.0.3 rxdart: ^0.21.0 flutter_html: ^0.9.6 sqflite: ^1.1.3 archive: ^2.0.8 percent_indicator: ^1.0.14 flutter_statusbarcolor: ^0.2.0 flutter_inappbrowser: ^1.1.1 scoped_model: ^1.0.1 #Firebase firebase_core: ^0.3.1+1 firebase_analytics: ^2.1.1
- build.gradle
buildscript { ext.kotlin_version = '1.2.71' repositories { google() jcenter() } dependencies { classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath 'com.google.gms:google-services:3.2.1' classpath 'com.android.tools.build:gradle:3.2.1' } } 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 } subprojects { project.configurations.all { resolutionStrategy.eachDependency { details -> if (details.requested.group == 'androidx.fragment' && !details.requested.name.contains('androidx')) { details.useVersion "1.0.0" } } } }
- 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 plugin: 'kotlin-android' > apply from: > "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" > > android { > compileSdkVersion 28 > > sourceSets { > main.java.srcDirs += 'src/main/kotlin' > } > > lintOptions { > disable 'InvalidPackage' > } > > defaultConfig { > // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). > applicationId "xxx" > minSdkVersion 21 > 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 { > implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" > 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' > > implementation 'com.google.firebase:firebase-core:16.0.8' } > > apply plugin: 'com.google.gms.google-services'
So what can I do to solve this? As I said it works on iOS and I can see the Analytics Dashboard ok in the Firebase console.
More info... If I open the Android module in Android Studio, it returns this gradle error: