unable to use firebase and location plugins through flutter and android - android

I've been working on this issue for 2 whole days now and am no closer to solving this.
I am using flutter, and after doing the codelabs tutorial for firebase, I tried adding location into the mix. My dependencies in pubspec.yaml, build.gradle, and app/build.gradle look like this.
pubspec.yaml
dependencies:
flutter:
sdk: flutter
# image_picker: 0.1.1 # new
# google_sign_in: 0.3.1 # new
# firebase_analytics: 0.0.4 # new
# firebase_auth: 0.2.0 # new
firebase_database: 0.0.12 # old
firebase_storage: 0.0.5 # old
# firebase_database: 0.4.6 # new
# firebase_storage: 0.3.3 # new
location: "^1.2.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'
}
}
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.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.takaoandrew.flutteralight"
minSdkVersion 21
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
// multiDexEnabled true
}
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'
// compile ("com.google.android.gms:play-services-base:10.0.1") {
// force = true;
// }
// compile ("com.google.android.gms:play-services-tasks:10.0.1") {
// force = true;
// }
// compile ("com.google.android.gms:play-services-basement:10.0.1") {
// force = true;
// }
}
apply plugin: 'com.google.gms.google-services'
The error I get doing this is
Execution failed for task ':app:preDebugBuild'.
Android dependency 'com.google.android.gms:play-services-base' has different version for the compile (11.0.4) and runtime (11.8.0) classpath. You should manually set the same version via DependencyResolution
I have tried manually overriding my play-services, but I don't know how to do this with flutter. Back when it was all android, I chose the version number myself. Uncommenting the following lines from app/build.gradle
// compile ("com.google.android.gms:play-services-base:10.0.1") {
// force = true;
// }
// compile ("com.google.android.gms:play-services-tasks:10.0.1") {
// force = true;
// }
// compile ("com.google.android.gms:play-services-basement:10.0.1") {
// force = true;
// }
gives me the error
Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
-- this is a classic error for me. Uncommenting the line
// multiDexEnabled true
in app/build.gradle doesn't change with the unable to merge dex error.
The dependencies seem to be a mess to me, so I tried looking at a dependency tree. I want to see my gradle dependencies to try and align everything. When I run ./gradlew :app/dependencies I get
FAILURE: Build failed with an exception.
What went wrong:
Could not determine java version from '10.0.1'.
Whether somebody knows what my issues are, or someone has helpful references to help me understand gradle dependencies, and how they relate to flutter dependencies, or how to resolve problems with 'dex', or any tips at all... I would greatly appreciate it because I am banging my head against the wall right now. I have tried other solutions I've seen in StackOverflow and nothing has worked. And the iOS version runs fine so far.

Related

Flutter build appbundle Error Could not find method androidExtensions() for arguments

I'm trying to build a release appbundle for an Andriod app using Flutter,
When I run:
flutter build appbundle
I get:
* What went wrong:
A problem occurred evaluating project ':app'.
> No signature of method: build_9z8dp8vvjumdxnixrakr4imyg.android() is applicable for argument
types: (build_9z8dp8vvjumdxnixrakr4imyg$_run_closure3) values: [buil
d_9z8dp8vvjumdxnixrakr4imyg$_run_closure3#775a0064]
I tried to clean+repair cache but its still not working. Flutter doctor works fine.
app\build.gradle file:
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'
}
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
apply plugin: 'org.jetbrains.kotlin.android.extensions'
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
androidExtensions {
experimental = true
}
android {
compileSdkVersion 30
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
applicationId "com.example.Application"
minSdkVersion 23
targetSdkVersion 30
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile keystoreProperties['storeFile']
storePassword keystoreProperties['storePassword']
}
}
buildTypes {
release {
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.release
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
flutter {
source '../..'
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
// Import the Firebase BoM
implementation platform('com.google.firebase:firebase-bom:27.1.0')
// Add the dependency for the Firebase SDK for Google Analytics
// When using the BoM, don't specify versions in Firebase dependencies
implementation 'com.google.firebase:firebase-analytics'
// Declare the dependency for the Firebase Authentication library
// When using the BoM, you don't specify versions in Firebase library dependencies
implementation 'com.google.firebase:firebase-auth'
// Add the dependencies for any other desired Firebase products
// https://firebase.google.com/docs/android/setup#available-libraries
implementation 'com.facebook.android:facebook-login:[8.1)'
implementation 'com.facebook.android:facebook-android-sdk:[5,6)'
implementation 'com.google.android.material:material:1.1.0'
implementation 'androidx.fragment:fragment:1.0.0'
}
apply plugin: 'com.google.gms.google-services'
android\build.gradle file:
buildscript {
ext.kotlin_version = '1.3.50'
repositories {
google()
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.google.gms:google-services:4.3.5'
classpath 'com.android.tools.build:gradle:4.2.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
google() // Google's Maven repository
jcenter()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
android\key.properties file:
storePassword=123456789
keyPassword=123456789
keyAlias=upload
storeFile=C:\\Users\\User\\Documents\\Application\\upload-keystore.jks
full output:
C:\Users\User\Documents\Application>flutter build appbundle
The plugin `flutter_open_whatsapp` uses a deprecated version of the Android embedding.
To avoid unexpected runtime failures, or future build failures, try to see if this plugin supports the Android V2 embedding. Otherwise, consider removing it since
a future release of Flutter will remove these deprecated APIs.
If you are plugin author, take a look at the docs for migrating the plugin to the V2 embedding: https://flutter.dev/go/android-plugin-migration.
Building without sound null safety
For more information see https://dart.dev/null-safety/unsound-null-safety
Kotlin plugin should be enabled before 'kotlin-android-extensions'
FAILURE: Build failed with an exception.
* Where:
Build file 'C:\Users\User\Documents\Application\android\app\build.gradle' line: 41
* What went wrong:
A problem occurred evaluating project ':app'.
> No signature of method: build_9z8dp8vvjumdxnixrakr4imyg.android() is applicable for argument types: (build_9z8dp8vvjumdxnixrakr4imyg$_run_closure3) values: [buil
d_9z8dp8vvjumdxnixrakr4imyg$_run_closure3#27144de8]
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 2s
Running Gradle task 'bundleRelease'... 2,990ms
Gradle task bundleRelease failed with exit code 1
Try opening the /android directory as a project in android studio and build the release without using Flutter.
Even try using Java for the project and see if it works or not ??
if it works, then there might be some issue with your Kotlin version.

Unable to add firebase to android (flutter)

I have been trying to resolve this issue since two days and I have also tried the solutions already present at Stack Overflow regarding this problem but did not succeed.
All the steps that I have followed are from Add Firebase to your Android app guide (The steps by Firebase Official)
PROJECT-LEVEL Build.gradle:
buildscript {
ext.kotlin_version = '1.2.71'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.google.gms:google-services:4.3.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
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-LEVEL 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 "com.example.loginapp"
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 {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.google.firebase:firebase-analytics:17.2.0'
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'
Pubspec.yaml File:
version: 1.0.0+1
environment:
sdk: ">=2.1.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.2
firebase_auth: ^0.14.0+9
dev_dependencies:
flutter_test:
sdk: flutter
Gradle-wrapper.properties:
#Fri Jun 23 08:50:38 CEST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip
ERROR:
PS D:\flutterworks\bhund> flutter run
Using hardware rendering with device Android SDK built for x86. If you get graphics artifacts, consider enabling software rendering with
"--enable-software-rendering".
Launching lib\main.dart on Android SDK built for x86 in debug mode...
Initializing gradle... 5.1s
Resolving dependencies...
* Error running Gradle:
ProcessException: Process "D:\flutterworks\bhund\android\gradlew.bat" exited abnormally:
Command: D:\flutterworks\bhund\android\gradlew.bat app:properties
Please review your Gradle project setup in the android/ folder.
PS D:\flutterworks\bhund>
I had the same problem and could not migrate to Androidx manually.
Note that it is necessary for projects to now be in Androidx if you want to use Firebase, or it may cause more problems later.
Step 1: In your project level gradle change:
classpath 'com.google.gms:google-services:4.3.2'
to:
classpath 'com.google.gms:google-services:3.2.0'
Usually after this step, your project will run fine, but it is import to migrate to AndroidX right now and not cause further errors while using Firebase.
Step 2: Once this is done, just make a new project with Androidx settings, you can do this by opening the flutter_console.bat and navigating to your desired folder then run:
flutter create --androidx your_project_name
on your flutter console.
Step 3: Navigate to your new project > android > gradle.properties and check if it has these two lines:
android.useAndroidX=true
android.enableJetifier=true
This means that the project has migrated to Androidx.
Step 4: Finally, move all your code from the old project to the new flutter project along with all the dependencies and plugins you may have added in the old project. (Including dependency in Step 1)
What you can try is just go to your project level build and change your classpath dependencies and kotlin version as below.
buildscript {
ext.kotlin_version = '1.3.21'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.0'
classpath 'com.google.gms:google-services:4.3.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
To add AndroidX in your flutter project, go to android package > gradle.properties
Inside gradle.properties add two lines.
android.useAndroidX=true
android.enableJetifier=true
This might work for you.

Execution failed for task ':app:preDebugBuild'.in Flutter

Android dependency 'com.android.support:support-media-compat' has different version for the compile (26.1.0) and runtime (27.1.1) classpath. You should manually set the same version via DependencyResolution
I have added List of plugins in my flutter app
dependencies:
flutter:
sdk: flutter
connectivity:
rxdart:
validate: ^1.7.0
image_picker: ^0.4.10
shared_preferences: "^0.4.2"
firebase_auth: ^0.6.2+1
google_sign_in:
Dart & Flutter version : Dart 2.1.0-dev.3.1.flutter-760a9690c2
This is my android app - 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.")
}
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.example.standardappstructure"
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 {
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'
Destribution Gradle version :
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
Project level : gradle
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.0'
classpath 'com.google.gms:google-services:4.0.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
}
If I am changing gradle classpath to
classpath 'com.android.tools.build:gradle:3.2.1'
Its showing me
Android dependency 'android.arch.lifecycle:runtime' has different version for the compile (1.0.0) and runtime (1.1.0) classpath. You should manually set the same version via DependencyResolution
You can solve this error with below code change in android>build.gradle
If your project config with kotlin then
ext.kotlin_version = '1.2.71'
replace with new version
ext.kotlin_version = '1.3.0'
and
dependencies {classpath 'com.android.tools.build:gradle:3.2.1'}
replace with new version
dependencies {classpath 'com.android.tools.build:gradle:3.3.0'}
You probably get your obstacles if your exception is
What went wrong:
Execution failed for task ':app:preDebugBuild'.
Android dependency 'androidx.exifinterface:exifinterface' has different version for the compile (1.0.0-rc01) and runtime (1.0.0) classpath. You should manually set the same version via DependencyResolution
I added implementation("com.android.support:support-v4:latest_version_number") to my build.gradle and it worked.Hope this helps.
cloud_firestore: ^0.8.2+3
firebase_auth: ^0.6.5
image_picker: 0.4.0
This works for me

com.google.gms:google-services Compatibility Issue with Firebase plugins

Trying to get an old project up to date today, I ran into an issue (on Android) which I believe has to do with one of the Firebase plugins.
I keep on getting the following error:
FAILURE: Build failed with an exception.
What went wrong:
The library com.google.android.gms:play-services-base is being requested by various other libraries at [[15.0.1,15.0.1]], but resolves to 11.8.0. Disable the plugin and check your dependencies tree using ./gradlew :app:dependencies.
Here is a snippet from my pubspec file to show the plugins in my project:
dependencies:
flutter:
sdk: flutter
firebase_auth: ^0.5.18
firebase_storage: ^1.0.1
cloud_firestore: ^0.7.4
firestore_helpers: ^2.0.5
image_picker: ^0.2.0
location: 1.1.6
flutter_webview_plugin: 0.0.9+1
font_awesome_flutter: 4.7.2
flutter_map: ^0.0.1
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.0
This snippet shows the project in its current state, with all the new versions for the Firebase products.
I did also update my build.gradle files of course, they look like this atm:
Android level build.gradle file:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.google.gms:google-services:4.0.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
}
App level build.gradle file:
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.test.tester"
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
}
profile {
matchingFallbacks = ['debug', 'release']
}
}
}
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'
I believe that is all that I had to do according to the docs, but perhaps I missed something.
Any one an idea on how to fix this?
open this link, this contains the list of Firebase libraries versions that you need to use

Unable to merge dex in flutter

Hi I am developing app in flutter. When I am trying to build flutter then I am getting an error Unable to merge dex.
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.")
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion 27
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 "com.xyz"
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 "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
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'
implementation 'com.google.firebase:firebase-core:16.0.0'
}
apply plugin: 'com.google.gms.google-services'
module build.gradle
buildscript {
ext.kotlin_version = '1.1.51'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.0.0'
}
}
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
}
Does anyone know how to resolve it in flutter ?
Try adding this in app build.gradle
android {
defaultConfig {
multiDexEnabled true
}
}
change
classpath 'com.google.gms:google-services:4.0.0'
implementation 'com.google.firebase:firebase-core:16.0.0'
to
classpath 'com.google.gms:google-services:4.0.1'
implementation 'com.google.firebase:firebase-core:16.0.1'
And also open the project in Android studio and
clean,
rebuild or simply run flutter clean command
take this steps :
clean the project by running flutter clean
rebuild using flutter build or run using flutter run.
i hope this will help .
Following this link solved a very similar issue for me.
** I did not not have to set multiDexEnabled to true
First I set dependencies in my pubspec.yaml to
dependencies:
flutter:
sdk: flutter
cloud_firestore: ^0.8.2
and ran flutter packages get in my IDE's terminal.
Also I had to change the minimum target SDK version:
Open android/app/build.gradle, then find the line that says
minSdkVersion 16.
Change that line to minSdkVersion 21.
Save the file.
This alone may fix your problem; however I had to also do the following because some of my dependency versions were mismatched.
I had to open android/app/build.gradle, then add the following line as the last line in the file:
apply plugin: 'com.google.gms.google-services'
Next, I had to open android/build.gradle, then inside the buildscript tag, add a new dependency:
buildscript {
repositories {
// ...
}
dependencies {
// ...
classpath 'com.google.gms:google-services:3.2.1' // new
}
}
After this my app finally ran on the android emulator.
The link has a more complete walkthrough if you get stuck.

Categories

Resources