I am new to flutter framework. I am trying to install cloud firestore in flutter but got the problem. Below is my code and gradle files:
Android/build.gradlew:
buildscript {
// ext.kotlin_version = '1.2.31'
repositories {
google()
jcenter()
maven {
url "https://maven.google.com"
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.google.gms:google-services:3.2.0'
}
}
allprojects {
repositories {
google()
jcenter()
maven {
url "https://maven.google.com"
}
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
App/build.gradle is:
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 from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion 28
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.barcode_app"
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 {
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'
After running flutter run -v or build it in android i got the error:
'ERROR: Plugin with id 'com.google.gms:google-services' not found.'
I tried to almost all the solution available on stackoverflow and github but the problem is still there.
At the bottom of your app/build.gradle file you've got:
apply plugin: 'com.google.gms:google-services'
This should actually be:
apply plugin: 'com.google.gms.google-services'
Notice the period between gms and google-services, instead of the colon.
EDIT: You're probably having this problem because Google's own docs (last edited 20 March) are incorrect. I've sent them feedback to have this corrected.
archived here http://archive.is/4Ujuc
Actually Google is correct: classpath 'com.google.gms:google-services:4.2.0' is correct and apply plugin: 'com.google.gms.google-services' is also correct. One has a COLON and one has a PERIOD. but the names are so similar that it is easy to think they should be the same.
Just remember "classpath" - COLON, "plugin" - PERIOD.
If the problem still persists after applying the Jmorris and Johnhunter solution, check this solution
The solution was:
Upgrade the Android Gradle plugin to 3.5.0
Upgrade the Google Services plugin to 4.3.3
Upgrade Gradle to 5.4.1 (the required Gradle version for this Android Gradle plugin version)
Just delete the google-services.json file and re configure the firebase with your project.
Related
I am trying to use Chaquopy Plugin in my android project generated with flutter. I mean that when a flutter project is created it generates an android project app folder with it. As Chaquopy does not provide direct support for flutter so I have decided to use this in that flutter generated android app. I went through the line-by-line of Chaquopy's documentation and tried to follow all the instructions given there. But I think I missed something and it is showing errors now and not downloading the Chaquopy Plugin. I am giving my settings.gradle and other gradle files below. Please help me. I am very new to programming and that's why I don't understand these stuff much
Here is the Chaquopy Documentation
Here is my Settings.gradle
include ':app'
def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
def properties = new Properties()
assert localPropertiesFile.exists()
localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }
def flutterSdkPath = properties.getProperty("flutter.sdk")
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle"
Here is my Project level Build.gradle
buildscript {
ext.kotlin_version = '1.6.10'
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.2.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
plugins {
id 'com.chaquo.python' version '12.0.1' apply false
}
allprojects {
repositories {
google()
mavenCentral()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Here is my 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"
plugins {
id 'com.chaquo.python'
}
android {
compileSdkVersion flutter.compileSdkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.pyflut"
minSdkVersion flutter.minSdkVersion
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
python {
buildPython "C:/Users/super/AppData/Local/Programs/Python/Python310/python.exe"
buildPython "C:/Users/super/AppData/Local/Programs/Python/Python310/python.exe", "-3.10"
}
}
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"
}
Finally here are my errors
Build file 'F:\Pyflut\android\build.gradle' line: 14
Error resolving plugin [id: 'com.chaquo.python', version: '12.0.1', apply: false]
> Could not resolve all dependencies for configuration 'detachedConfiguration1'.
> Could not determine artifacts for com.chaquo.python:com.chaquo.python.gradle.plugin:12.0.1
> Could not get resource 'https://plugins.gradle.org/m2/com/chaquo/python/com.chaquo.python.gradle.plugin/12.0.1/com.chaquo.python.gradle.plugin-12.0.1.jar'.
> Could not HEAD 'https://jcenter.bintray.com/com/chaquo/python/com.chaquo.python.gradle.plugin/12.0.1/com.chaquo.python.gradle.plugin-12.0.1.jar'.
> Read timed out
* Try:
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
* Exception is:
org.gradle.api.GradleException: Error resolving plugin [id: 'com.chaquo.python', version: '12.0.1', apply: false]
at org.gradle.plugin.use.internal.DefaultPluginRequestApplicator.resolveToFoundResult(DefaultPluginRequestApplicator.java:215)...... [Can not copy full error because of character limitaions sorry for that but if it needs then I will provide you that
As others have mentioned, it looks like the Gradle plugin portal is having some problems today.
Since your Flutter-generated project uses the old buildscript and apply syntax to apply the Android plugin, you should probably follow the same pattern with the Chaquopy plugin. That way, the Gradle plugin portal won't even be involved. See this version of the Chaquopy documentation for an example.
Alternatively, you can continue to apply the Chaquopy plugin with the new plugins syntax, but also include mavenCentral in the pluginManagement { repositories } block in settings.gradle. That should allow you to access the plugin without relying on the Gradle plugin portal's mirror. See here for an example.
Jcenter is down mate. We don't know how long it will be because there is no blogpost or social media post about it.
Check it here: https://status.bintray.com/
I am getting the following error when trying to debug my flutter app on my phone
FAILURE: Build failed with an exception.
What went wrong: A problem occurred configuring root project 'android'.
compileSdkVersion is not specified. Please add it to build.gradle
My app build. gradle file is as follows:
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 FileNotFoundException("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 from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion 30
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.wizzcrete"
minSdkVersion 23
targetSdkVersion 30
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
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 '../..'
}
My android build.gradle file is as follows:
buildscript {
repositories {
google()
jcenter()
maven {
url "https://maven.google.com"
}
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.0'
classpath 'com.google.gms:google-services:4.0.1'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
project.evaluationDependsOn(':app')
}
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
I have checked my SDK version and it is indeed 30. I even experimented with using the Android SDK version 29 and updating the compile and target SDK version to 29 in the gradle and that still did not work. My minSDK version is 23 as in order to use firebase in flutter minimum 23 is required. I hope this information is enough to convey the problem, any ideas?
SOLVED
The issue was that I did not add all the necessary firebase dependencies to my project level gradle. The plugins I added were in the app level gradle which was wrong, they were supposed to be in the Project level gradle. Additionally, I had to add missing dependencies such as the implementation fo the firebase core bom and the firestore and authentication dependencies to my project level gradle like so:
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation platform('com.google.firebase:firebase-bom:28.4.0')
implementation 'com.google.firebase:firebase-auth'
implementation 'com.google.firebase:firebase-firestore-ktx'
}
I am adding this answer to help another lost soul like mine was for 6+ hours wracking my brains on this issue. To sum it up: check the dependencies in both your gradle files and make sure you have all of it sorted out.
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
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.
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.