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

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

Related

Flutter Android Build Failed : com.android.tools.r8.CompilationFailedException: Compilation failed to complete

Been trying for days; googling and trying all sorts of 'fixes' and 'dependencies' etc but still not able to build APK for release. Debug is ok.
My command: flutter build apk --release
error:
AILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:transformClassesAndResourcesWithR8ForRelease'.
com.android.tools.r8.CompilationFailedException: Compilation failed to complete
BUILD FAILED in 2m 1s
Running Gradle task 'assembleRelease'...
Running Gradle task 'assembleRelease'... Done 147.3s (!)
[!] The shrinker may have failed to optimize the Java bytecode.
To disable the shrinker, pass the --no-shrink flag to this command.
To learn more, see: https://developer.android.com/studio/build/shrink-code
Gradle task assembleRelease failed with exit code 1
build.grade (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.")
}
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
throw new GradleException("versionCode not found. Define flutter.versionCode in the local.properties file.")
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'4
throw new GradleException("versionName not found. Define flutter.versionName in the local.properties file.")
}
apply plugin: 'com.android.application'
// 20/2/20
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
// 20/2/20
apply plugin: 'com.google.gms.google-services'
// Add the Fabric plugin. 10 March 2020
apply plugin: 'io.fabric'
def keystorePropertiesFile = rootProject.file("key.properties")
def keystoreProperties = new Properties()
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
def kotlin_version = '1.3.21'
android {
compileSdkVersion 28
// 20/2/20
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 "net.hotsource.peribuddy"
minSdkVersion 24
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
//testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
// Enabling multidex support.
multiDexEnabled true
}
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile file(keystoreProperties['storeFile'])
storePassword keystoreProperties['storePassword']
}
}
buildTypes {
release {
minifyEnabled true
//shrinkResources true
//useProguard true
//proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
ndk {
abiFilters 'armeabi-v7a', 'arm64-v8a'
}
}
debug {
// minifyEnabled true
}
}
}
flutter {
source '../..'
}
dependencies {
// 28 May 2019
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'androidx.appcompat:appcompat:1.1.0' // 1.0.2
implementation 'com.facebook.android:facebook-android-sdk:[5,6)'
implementation 'com.android.support:multidex:1.0.3'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
// 10 March 2020
// (Recommended) Add the Google Analytics dependency.
implementation 'com.google.firebase:firebase-analytics:17.4.2' // 17.2.3
// Add the Firebase Crashlytics dependency.
implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1'
implementation 'com.google.firebase:firebase-messaging:20.2.0'
implementation "com.android.support:support-v4:28.0.0"
implementation "com.android.support:support-fragment:28.0.0"
implementation 'com.google.firebase:firebase-firestore:21.4.3'
implementation 'com.google.firebase:firebase-firestore-ktx:21.4.3'
}
// firebase_crashlytics
apply plugin: 'io.fabric'
apply plugin: 'com.google.gms.google-services'
build.gradle (project):
version '1.0-SNAPSHOT'
buildscript {
ext.kotlin_version = '1.3.50'
repositories {
google()
jcenter()
// For Crashlytics SDK
maven {
url 'https://maven.fabric.io/public'
}
}
dependencies {
classpath 'com.android.tools:r8:1.6.84' // Must be before the Gradle Plugin for Android.
classpath 'com.android.tools.build:gradle:3.4.2' // 3.1.2 3.3.0-alpha13 4.10.2 330 3.3.2 3.6.3
// classpath 'com.google.gms:google-services:4.2.0' // 3.2.1 4.0.1 4.1.0 4.3.3
classpath 'com.google.gms:google-services:4.2.0'
// Add the Fabric Crashlytics plugin. 10 march 2020 1.31.2
classpath 'io.fabric.tools:gradle:1.31.2'
//classpath 'io.fabric.tools:gradle:1.+' // new
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// Add fabric classpath
//classpath 'io.fabric.tools:gradle:1.26.1'
}
}
allprojects {
repositories {
google()
jcenter()
}
configurations.matching { it.name == '_internal_aapt2_binary' }.all { config ->
config.resolutionStrategy.eachDependency { details ->
details.useVersion("3.5.0-alpha03-5252756")
}
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
the problem, in Android studio related with jdk version. you can go through project structure and change Gradle's jdk. wish it will solve.
In My case,
after i run with -verbose
flutter build apk -v
"MainActivity is defined multiple times"
after removed one of that apk build successful.
MainActivity found in both kotin & java subfolder in android folder
this happens when i add external plugin
face the similar issue. what I did is just disable R8.
as in your terminal :
flutter build apk --no-shrink
or in your app level build.gradle:
minifyEnabled false
shrinkResources false
then build apk as normal
by the way, my apk works without R8, because I don't know how to stop it deleting my files

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.

com.google.android.gms:play-services-basement is being requested by various other libraries at [[15.0.1,15.0.1]], but resolves to 11.8.0

My Build failed, This was the error.
FAILURE: Build failed with an exception.
* What went wrong:
Failed to notify dependency resolution listener.
> The library com.google.android.gms:play-services-basement 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.
> The library com.google.firebase:firebase-analytics is being requested by various other libraries at [[16.0.1,16.0.1]], but resolves to 11.8.0. Disable the plugin and check your dependencies tree using ./gradlew :app:dependencies.
Below is the root Gradle file.
buildscript {
ext.kotlin_version = '1.2.31'
repositories {
google()
jcenter()
maven {
url "https://maven.google.com" // Google's Maven repository
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.google.gms:google-services:4.0.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
google()
jcenter()
maven {
url "https://maven.google.com" // Google's Maven repository
}
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
And this is the app 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.")
}
apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
apply plugin: 'kotlin-android'
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.yourcompany.login"
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.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
androidTestImplementation 'com.google.firebase:firebase-core:16.0.3'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
implementation 'com.google.firebase:firebase-core:16.0.3'
}
apply plugin: 'com.google.gms.google-services'
Any help is greatly appreciated. Of what I think this a compatibility issue and I got no success searching the same errors on different forums.
P.S: I am a newbie, so spare me on the downvotes if you find that my question is not framed properly.

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