Coder Social home page Coder Social logo

Comments (10)

elhe26 avatar elhe26 commented on August 26, 2024 7

This solution worked for me:

  • android_folder/build.gradle:
dependencies {
        classpath 'com.android.tools.build:gradle:3.5.0' // latest version
        classpath 'com.google.gms:google-services:4.3.1' // latest version
    }
  • gradle/wrapper/gradle-wrapper.properties
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip # latest version
  • android_folder/app/build.gradle:
dependencies {
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
    implementation 'com.google.firebase:firebase-analytics:17.0.1'
    implementation 'com.google.firebase:firebase-messaging:19.0.1' // Line added 
}

apply plugin: 'com.google.gms.google-services'

from flutterfire.

hmmdeif avatar hmmdeif commented on August 26, 2024 3

Ok so I managed to get this to run after the upgrade to 5.1.6. I also recreated my project by starting a brand new flutter project and then copying my dart files to the new project (as new projects are created with kotlin files now).

The way I could get it to work is changing quite a few settings that is not in the main installation documentation as follows:

android/build.gradle

buildscript {
    ext.kotlin_version = '1.3.41'
    repositories {
        google()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.google.gms:google-services:4.3.2'
    }
}

android/app/build.gradle

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-messaging:20.0.0'
}

apply plugin: 'com.google.gms.google-services'

android/gradle/wrapper/gradle-wrapper-properties

distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip

Haven't tested if the notifications actually work but at least the project builds.

from flutterfire.

pablomdd avatar pablomdd commented on August 26, 2024

I tried that @ericklhe , didn´t work for me, show the same error from before updating the Graddle

from flutterfire.

elhe26 avatar elhe26 commented on August 26, 2024

@pablomdd, could you please post your configuration files (app/build.gradle, etc..)?

Also, please use the latest libraries from pub. You could use Flutter Enhancement suite on Android Studio. This plugin will help you out on this manner (it'll check if you need to upgrade your libraries).

from flutterfire.

hmmdeif avatar hmmdeif commented on August 26, 2024

Pretty sure I have the same error. Platform I'm on is Windows 10 and developing in VSCode.

  • android/build.gradle
buildscript {
    ext.kotlin_version = '1.2.71'
    repositories {
        google()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.google.gms:google-services:4.3.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
}
  • android/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 "com.example.test_proj"
        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"
    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-messaging:19.0.1'
}

apply plugin: 'com.google.gms.google-services'
  • android/gradle/wrapper/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-5.4.1-all.zip

AndroidManifest.xml is unchanged. And google-settings.json is located in android/app/google-settings.json.

All I did was create a new flutter project, add firebase_messaging: ^5.1.5, then change the above files and gradle errors as per OP.

If I change the dependencies to classpath 'com.android.tools.build:gradle:3.5.0' from 3.2.1 I get a different error message:

Initializing gradle...                                              0.5s
Resolving dependencies...
* Error running Gradle:
ProcessException: Process "<WINDOWS_ROOT>\test_proj\android\gradlew.bat" exited abnormally:

> Configure project :app
WARNING: API 'variant.getMergeResources()' is obsolete and has been replaced with 'variant.getMergeResourcesProvider()'.
It will be removed at the end of 2019.
For more information, see https://d.android.com/r/tools/task-configuration-avoidance.
To determine what is calling variant.getMergeResources(), use -Pandroid.debug.obsoleteApi=true on the command line to display more information.
WARNING: API 'variant.getJavaCompile()' is obsolete and has been replaced with 'variant.getJavaCompileProvider()'.
It will be removed at the end of 2019.
For more information, see https://d.android.com/r/tools/task-configuration-avoidance.
To determine what is calling variant.getJavaCompile(), use -Pandroid.debug.obsoleteApi=true on the command line to display more information.
WARNING: API 'variant.getMergeAssets()' is obsolete and has been replaced with 'variant.getMergeAssetsProvider()'.
It will be removed at the end of 2019.
For more information, see https://d.android.com/r/tools/task-configuration-avoidance.
To determine what is calling variant.getMergeAssets(), use -Pandroid.debug.obsoleteApi=true on the command line to display more information.
WARNING: API 'variantOutput.getProcessResources()' is obsolete and has been replaced with 'variantOutput.getProcessResourcesProvider()'.
It will be removed at the end of 2019.
For more information, see https://d.android.com/r/tools/task-configuration-avoidance.
To determine what is calling variantOutput.getProcessResources(), use -Pandroid.debug.obsoleteApi=true on the command line to display more information.
         *********************************************************
WARNING: This version of firebase_messaging will break your Android build if it or its dependencies aren't compatible with AndroidX.
         See https://goo.gl/CP92wY for more information on the problem and how to fix it.
         This warning prints for all Android build failures. The real root cause of the error may be unrelated.
         *********************************************************
  Command: <WINDOWS_ROOT>\test_proj\android\gradlew.bat app:properties


Please review your Gradle project setup in the android/ folder.

Original error message:

Initializing gradle...                                              0.6s
Resolving dependencies...
* Error running Gradle:
ProcessException: Process "<WINDOWS_ROOT>\test_proj\android\gradlew.bat" exited abnormally:

FAILURE: Build failed with an exception.

* Where:
Build file <WINDOWS_ROOT>\test_proj\android\app\build.gradle' line: 24

* What went wrong:
A problem occurred evaluating project ':app'.
> ASCII

* 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 1s
  Command: <WINDOWS_ROOT>\test_proj\android\gradlew.bat app:properties


Please review your Gradle project setup in the android/ folder.

Should be pretty straight forward to reproduce.

from flutterfire.

elhe26 avatar elhe26 commented on August 26, 2024

I tried to reproduce these issues using different scenarios, and I found out that the issue here is with the kotlin version (project_folder/build.gradle).

Please change ext.kotlin_version from this:

ext.kotlin_version = '1.2.71'

to this:

ext.kotlin_version = '1.3.41'

You also need to upgrade the dependencies on project_folder/build.gradle:

classpath 'com.android.tools.build:gradle:3.5.0' // latest version
classpath 'com.google.gms:google-services:4.3.2'  // latest version

and gradle-wrapper.properties:

distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip

Remember to add implementation 'com.google.firebase:firebase-messaging:20.0.0'
in app/build.gradle.

from flutterfire.

hmmdeif avatar hmmdeif commented on August 26, 2024

@ericklhe That has changed the error message. I've managed to identify the issue for this error message, it's something to do with the google-services dependency as it all works fine with the updated versions until I add google-services to the build.gradle files.

The error I get now is:

[        ] > Task :app:processDebugGoogleServices FAILED
[        ] 12 actionable tasks: 5 executed, 7 up-to-date
[ +326 ms] Running Gradle task 'assembleDebug'... (completed in 8.7s)
[   +2 ms] "flutter run" took 12,355ms.
Gradle task assembleDebug failed with exit code 1

#0      throwToolExit (package:flutter_tools/src/base/common.dart:28:3)
#1      _buildGradleProjectV2 (package:flutter_tools/src/android/gradle.dart:751:5)
<asynchronous suspension>
#2      buildGradleProject (package:flutter_tools/src/android/gradle.dart:494:14)
<asynchronous suspension>
#3      buildApk (package:flutter_tools/src/android/apk.dart:34:9)
<asynchronous suspension>
#4      AndroidDevice.startApp (package:flutter_tools/src/android/android_device.dart:486:13)
<asynchronous suspension>
#5      FlutterDevice.runHot (package:flutter_tools/src/resident_runner.dart:378:54)
<asynchronous suspension>
#6      HotRunner.run (package:flutter_tools/src/run_hot.dart:254:39)
<asynchronous suspension>
#7      RunCommand.runCommand (package:flutter_tools/src/commands/run.dart:472:37)
<asynchronous suspension>
#8      FlutterCommand.verifyThenRunCommand (package:flutter_tools/src/runner/flutter_command.dart:490:18)
#9      _asyncThenWrapperHelper.<anonymous closure> (dart:async-patch/async_patch.dart:71:64)
#10     _rootRunUnary (dart:async/zone.dart:1132:38)
#11     _CustomZone.runUnary (dart:async/zone.dart:1029:19)
#12     _FutureListener.handleValue (dart:async/future_impl.dart:137:18)
#13     Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:678:45)
#14     Future._propagateToListeners (dart:async/future_impl.dart:707:32)
#15     Future._completeWithValue (dart:async/future_impl.dart:522:5)
#16     _AsyncAwaitCompleter.complete (dart:async-patch/async_patch.dart:30:15)
#17     _completeOnAsyncReturn (dart:async-patch/async_patch.dart:288:13)
#18     RunCommand.usageValues (package:flutter_tools/src/commands/run.dart)
#19     _asyncThenWrapperHelper.<anonymous closure> (dart:async-patch/async_patch.dart:71:64)
#20     _rootRunUnary (dart:async/zone.dart:1132:38)
#21     _CustomZone.runUnary (dart:async/zone.dart:1029:19)
#22     _FutureListener.handleValue (dart:async/future_impl.dart:137:18)
#23     Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:678:45)
#24     Future._propagateToListeners (dart:async/future_impl.dart:707:32)
#25     Future._completeWithValue (dart:async/future_impl.dart:522:5)
#26     _AsyncAwaitCompleter.complete (dart:async-patch/async_patch.dart:30:15)
#27     _completeOnAsyncReturn (dart:async-patch/async_patch.dart:288:13)
#28     AndroidDevice.isLocalEmulator (package:flutter_tools/src/android/android_device.dart)
#29     _asyncThenWrapperHelper.<anonymous closure> (dart:async-patch/async_patch.dart:71:64)
#30     _rootRunUnary (dart:async/zone.dart:1132:38)
#31     _CustomZone.runUnary (dart:async/zone.dart:1029:19)
#32     _FutureListener.handleValue (dart:async/future_impl.dart:137:18)
#33     Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:678:45)
#34     Future._propagateToListeners (dart:async/future_impl.dart:707:32)
#35     Future._completeWithValue (dart:async/future_impl.dart:522:5)
#36     Future._asyncComplete.<anonymous closure> (dart:async/future_impl.dart:552:7)
#37     _rootRun (dart:async/zone.dart:1124:13)
#38     _CustomZone.run (dart:async/zone.dart:1021:19)
#39     _CustomZone.runGuarded (dart:async/zone.dart:923:7)
#40     _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:963:23)
#41     _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
#42     _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
#43     _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:116:13)
#44     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:173:5)

At this point I haven't even added firebase_messaging as an implementation or to my pubspec.yaml.

from flutterfire.

matiasalbarenque avatar matiasalbarenque commented on August 26, 2024

Ok so I managed to get this to run after the upgrade to 5.1.6. I also recreated my project by starting a brand new flutter project and then copying my dart files to the new project (as new projects are created with kotlin files now).

The way I could get it to work is changing quite a few settings that is not in the main installation documentation as follows:

android/build.gradle

buildscript {
    ext.kotlin_version = '1.3.41'
    repositories {
        google()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.google.gms:google-services:4.3.2'
    }
}

android/app/build.gradle

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-messaging:20.0.0'
}

apply plugin: 'com.google.gms.google-services'

android/gradle/wrapper/gradle-wrapper-properties

distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip

Haven't tested if the notifications actually work but at least the project builds.

The project builds perfectly and notifications are working!! Thank you very much!

from flutterfire.

iapicca avatar iapicca commented on August 26, 2024

Hi @masami6871
I see there's an open issue addressing the case you described.
Please follow up on that issue,
I'm closing the current one as duplicate.
If you disagree please write in the comments
and I will reopen it.
Thank you

from flutterfire.

hebersousa avatar hebersousa commented on August 26, 2024

I get the same here. I found that on mac and linux it works, but not on windows.

Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
> Could not resolve all task dependencies for configuration ':app:debugCompileClasspath'.
   > Could not resolve com.google.firebase:firebase-iid:[20.2.0].
     Required by:
         project :app > com.google.firebase:firebase-messaging:20.2.0
      > Failed to list versions for com.google.firebase:firebase-iid.
         > Unable to load Maven meta-data from https://dl.google.com/dl/android/maven2/com/google/firebase/firebase-iid/maven-metadata.xml.
            > org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; O conte�do n�o � permitido no pr�logo.
      > Failed to list versions for com.google.firebase:firebase-iid.
         > Unable to load Maven meta-data from https://dl.google.com/dl/android/maven2/com/google/firebase/firebase-iid/maven-metadata.xml.
            > org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; O conte�do n�o � permitido no pr�logo.

androis/build.gradle

dependencies {
      classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
      classpath 'com.google.gms:google-services:4.3.3'
      classpath 'com.android.tools.build:gradle:3.5.3'
  }

app/build.gradle

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
    implementation 'com.google.firebase:firebase-messaging:20.2.0'

}
apply plugin: 'com.google.gms.google-services'

from flutterfire.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.