Flutter app stops on launch when Firebase Analytics is added - android

I create an app using flutter create --org com.myorganisation --project-name myProjectName myAppName. By default, at the time of writing, it generates a Flutter project with the native parts written in Kotlin and Swift.
Everything is going fine -- I can launch the default app in Android on a real device. Then I start to get Firebase set up in the project. Following the instructions at https://firebase.google.com/docs/flutter/setup, I modify the project level and app level build.gradle, and add the relevant plugins to pub spec.yaml.
With firebase_core installed, the Android app still launches, but as soon as I add firebase_analytics: ^5.0.6, it stops on launch with no information in the Debug console and the Dart Dev Tools unavailable.

Running the project in Android Studio, I find the error message
ERROR: The Android Gradle plugin supports only Kotlin Gradle plugin version 1.3.10 and higher.
The following dependencies do not satisfy the required version:
root project 'android' -> org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.71
So then going back into the project level build.gradle file, I changed
buildscript {
ext.kotlin_version = '1.2.71'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.2'
}
}
to
buildscript {
ext.kotlin_version = '1.3.50'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.2'
}
}
And that change allowed Firebase Analytics to work.

Related

Firebase crashlytics error: Unable to load class 'org.gradle.api.tasks.TaskProvider'

I am trying to update fabric to Firebase crashlytics .
I followed their starting guide given here
The error I am getting are below:
(build.gradle) module-level:
I am using Gradle version: 4.6
distributionUrl=https://services.gradle.org/distributions/gradle-4.6-all.zip
Let me know if needed more info.
OK, Updated Android studio to the latest stable - 4.1
Updated Kotlin to the latest version - 1.14.10
Here's my build gradle file:
buildscript {
ext.kotlin_version = '1.4.10'
repositories {
google()
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:4.1.0"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.4'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.3.0'
}
}
Also, gradle version should be 6.5 in gradle-wrapper.proporties file
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip
It's all working now.

Could not find com.android.tools.build:gradle:5.4.1

I just turned on an old computer and am trying to access some code. After updating all of my Android Studio, JDK, and Downloading the latest Gradle I am having trouble building the project. I get this error ;
ERROR: Could not find com.android.tools.build:gradle:5.4.1.
Searched in the following locations:
- https://jcenter.bintray.com/com/android/tools/build/gradle/5.4.1/gradle-5.4.1.pom
- https://jcenter.bintray.com/com/android/tools/build/gradle/5.4.1/gradle-5.4.1.jar
Required by:
project :
Add Google Maven repository and sync project
Open File
I have dont this and this
Below is the content of build.gradle file
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:5.4.1'
}
}
Below is the content of wrapper file
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
in my settings I have toggled between default and setting my path manually. I have also attemted to add google() and MavenCentral() to the repositories
I just ant to build and run my app but it is saying no! haha help
Don't confuse gradle with the Android Gradle plugin.
classpath 'com.android.tools.build:gradle:5.4.1'
It is the Android Gradle plugin and 5.4.1 doesn't exist.
Use the latest stable release:
classpath 'com.android.tools.build:gradle:3.4.1'
Check the release notes for other versions.
If you open URL https://jcenter.bintray.com/com/android/tools/build/gradle, there is no 5.4.1.
For gradle version meanings, please check What is real Android Studio Gradle Version?.
For your case, you need to add google() repo in your buildscript closure and modify the android-gradle-plugin version to be 3.4.1
buildscript {
repositories {
google()// <-- add this.
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.1'
}
And, also, probably, you need to update your allprojects closure as below:
allprojects {
repositories {
google()// <-- add this.
jcenter()
}
}
Edit #1
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
This is the wrapper configuration telling which gradle version to use for your android gradle plugin. It is NOT the plugin version.

org.gradle.api.resources.ResourceException: Could not get resource in Android Studio 3.2

I tried to sync the gradle and I got this problem. Can anyone help me?
org.gradle.api.resources.ResourceException: Could not get resource 'https://dl.google.com/dl/android/maven2/com/google/firebase/firebase-measurement-connector-impl/17.0.3/firebase-measurement-connector-impl-17.0.3-javadoc.jar'.
and is this problem related to why I cannot connect my app to firebase?
Selvin's edit:
steps to reproduce: create any project android project with dependencies
dependencies {
implementation 'com.google.firebase:firebase-core:16.0.5'
}
(for me it's compile) gradle 4.6 with:
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.google.gms:google-services:4.2.0'
}
but spams Build -> Sync log with
Download https://dl.google.com/dl/android/maven2/com/google/firebase/firebase-core/16.0.5/firebase-core-16.0.5-javadoc.jar
Download https://dl.google.com/dl/android/maven2/com/google/firebase/firebase-measurement-connector-impl/17.0.3/firebase-measurement-connector-impl-17.0.3-javadoc.jar
if you try to open both URLs they return HTTP 204(No Content)
Question how can I stop gradle from spamming with those messages for every sync?
You need to write this in your app gradle file
classpath 'com.android.tools.build:gradle:3.4.1'
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
May be it's work
Try this in Build Gradle:
classpath 'com.android.tools.build:gradle:3.0.1'
Open settings -> Build -> Gradle -> Android Studio -> Check (Enable emmbedded maven repository)

Could not find com.android.tools.build.gradle:3.0.0-alpha7

I update the gradle plugin to the latest, and i'm getting this error:
Error:Could not find com.android.tools.build.gradle:3.0.0-alpha7:.
Searched in the following locations:
file:/C:/Users/dmin/Documents/android-studio/gradle/m2repository/com/android/tools/build/gradle/3.0.0-alpha7//3.0.0-alpha7-.pom
file:/C:/Users/dmin/Documents/android-studio/gradle/m2repository/com/android/tools/build/gradle/3.0.0-alpha7//3.0.0-alpha7-.jar
https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.0-alpha7//3.0.0-alpha7-.pom
https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.0-alpha7//3.0.0-alpha7-.jar
https://maven.google.com/com/android/tools/build/gradle/3.0.0-alpha7//3.0.0-alpha7-.pom
https://maven.google.com/com/android/tools/build/gradle/3.0.0-alpha7//3.0.0-alpha7-.jar
Here's my build.gradle
buildscript {
repositories {
jcenter()
maven { url 'https://maven.google.com' }
}
dependencies {
classpath 'com.android.tools.build.gradle:3.0.0-alpha7'
classpath 'com.google.gms:google-services:3.1.0'
}
}
allprojects {
repositories {
jcenter()
}
}
Where i'm getting wrong? since i modified my gradle.build according to the question Could not find com.android.tools.build:gradle:3.0.0-alpha1 in circle ci
thank you!!
-- Updated the build.gradle according to Mr Tim, but i'm still having the same error
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build.gradle:3.0.0-alpha7'
classpath 'com.google.gms:google-services:3.1.0'
}
}
allprojects {
repositories {
jcenter()
}
}
Follow the steps in the 3.0.0 plugin migration guide
Update gradle version
The new Android plugin requires Gradle version 4.1-milestone-1 or
higher. If you're opening an existing project using Android Studio 3.0
Preview 5 or later, follow the prompts to automatically update an
existing project to the compatible version of Gradle.
To update Gradle manually, update the URL in gradle-wrapper.properties
as follows:
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-milestone-1-all.zip
and
Apply the plugin
If you're opening an existing project using Android
Studio 3.0 Preview 5 or later, follow the prompts to automatically
update your project to the latest version of the Android plugin. To
manually update your project, include the maven repo and change the
plugin version in your project-level build.gradle file as follows:
buildscript {
repositories {
...
// You need to add the following repository to download the
// new plugin.
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1' //Minimum supported Gradle version is 4.6
}
}
You try :
buildscript {
repositories {
...
// You need to add the following repository to download the
// new plugin.
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
}
}
Credits: https://developer.android.com/studio/build/gradle-plugin-3-0-0-migration.html
If you're in Android Studio 3.1 or higher, you're likely encounter such type of issue prompting by a Build window.
Simply click on the Add Google Maven repository and sync project option at right side and initiate another gradle sync.
It'll make the necessary changes in both gradle-wrapper.properties as well as build.gradle files.
Update gradle plugin : in gradle.properties file
add this line
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
then apply ther plugin in build.gradle file :
buildscript {
repositories {
...
// You need to add the following repository to download the
// new plugin.
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
}
}
the distributionUrl property inside gradle-wrapper.properties should be:
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
that works for me
open the file path(just as the log said):
file:/C:/Users/dmin/Documents/android-studio/gradle/m2repository/com/android/tools/build/gradle/
found this file
just change classpath 'com.android.tools.build.gradle:3.0.0-alpha7'
to classpath 'com.android.tools.build.gradle:* * * ' ; * * * is the exist gradle file;
this problem is because of gradle file do not found

Outdated Kotlin Runtime warning in Android Studio

After downloaded and installed latest Kotlin plugin I have Outdated Kotlin Runtime warning from Android Studio that telling me:
Your version of Kotlin runtime in 'kotlin-stdlib-1.1.2' library is
1.1.2, while plugin version is 1.1.2-release-Studio2.3-3. Runtime library should be updated to avoid compatibility problems.
I tried to click Update Runtime button but getting another message:
Automatic library version update for Gradle projects is currently
unsupported. Please update your build.gradle manually.
How to solve this issue?
In your (Project: [projectName]) build.gradle file find this:
ext.kotlin_version = 'x.x.x' and replace x.x.x with the current version of your Kotlin plugin.
In order to check which is the current version of your Kotlin plugin:
Go to: Tools -> Kotlin -> Confugure Kotlin Plugin Updates
Click "Check again". After a second you will see the version of your Kotlin plugin. (If not up to date, your Kotlin plugin will be updated.)
N.B.: Also check your (Module: app) build.gradle file and assure that you do not use:
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:1.2.21"
but
compile 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.2.40'
Note the difference "...jre7..." -> "...jdk7...". Also replace "1.2.40" with your current Kotlin plugin version.
You can update your Kotlin version in your project level build.gradle file. If you have it configured the usual way, you should have the following line in it around the top:
ext.kotlin_version = '1.1.2'
To upgrade to the version matching your plugin, simply change this line to:
ext.kotlin_version = '1.1.2-3'
Edit (to respond to a question below):
The error tells you that you need to upgrade your version, the question is where to find out that you have to put in 1.1.2-3 instead of saying, for example, 1.1.2-release-Studio2.3-3.
The best way to find out the latest version of Kotlin is by going to kotlinlang.org and looking for "Latest version". Should be right there on the front page.
Another thing to do if the version number is non-trivial like this is to check the repositories where the versions are hosted. In the case of Android, you'll probably be getting it from jcenter, for which you can find the repository page, which has all the available versions listed.
You can also browse the raw maven repository of jcenter where the files are actually hosted by going here, or look up Kotlin either on mvnrepository or on mavencentral (raw version of the latter here).
it complained (on Android Studio 3.0.1) ...most likely because of referenced libraries' dependencies:
Your version of Kotlin runtime in 'org.jetbrains.kotlin:kotlin-stdlib:1.1.3#jar' library is 1.1.3, while plugin version is 1.1.51-release-Studio3.0-1.
then I've enforced building against the version it demanded, in the module level build.gradle:
configurations.all() {
resolutionStrategy.force 'org.jetbrains.kotlin:kotlin-stdlib:1.1.51'
}
and the result is:
./gradlew app:dependencies | grep kotlin
Download https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-stdlib/1.1.51/kotlin-stdlib-1.1.51.pom
| | +--- org.jetbrains.kotlin:kotlin-stdlib:1.1.3 -> 1.1.51
...
There are two pieces you may want to update:
kotlin runtime for the project
kotlin plugin
The answer by Ivo Stoyanov shows how to do this using the android studio menus. When I got the error message and tried this (updating the kotlin plugin) alone, it still complained about the kotlin runtime. You can update that on a project by project basis, by adding the line on ext.kotlin_version to the project build gradle, as some of the other answers indicate. But you'll need to know the kotlin runtime version for that. Alternatively, you can also do it through the menus, as I show here below, with the bonus that android studio shows you the available versions, and you can pick the most recent.
And then android studio will add in the appropriate line in your project build gradle.
changing your ext.kotlin_version from '1.1.2-4'to ext.kotlin_version = '1.1.2-5' solved the problem for me
the latest version of kotlin is 1.2.41 use this and syn your project.
buildscript {
ext.kotlin_version = '1.2.41'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
As of March 8, 2019 the current kotlin version is '1.3.21'
Under build.gradle
buildscript {
ext.kotlin_version = '1.3.21'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
cheers
This issue comes when you update the kotlin plugin version popped up from android studio, but issue is current version of Android studio is not able to dynamically change the kotlin gradle plugin which is located in your project level Build.gradle file.
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.10"
}
How to solve this issue?
So you need to manually change this version, You can find that Here
I've run into this issue a few times in Android Studio and IDEA, found that if you go into your projects Gradle file and in your dependencies if you set the version of the kotlin-gradle-plugin to $kotlin_version then the warning message will tell you what version you need to set ext.kotlin_version to.
buildscript {
ext.kotlin_version = '1.2.40'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
buildscript {
ext.kotlin_version = '1.2.50'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
search for these two lines of code
ext.kotlin_version = '1.3.11'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
replace $kotlin_version with actual value (here it's 1.3.11)
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.11"
after this your IDE will automatically suggest you the updated version
happy coding :)
Kotlin newest version:
buildscript {
ext.kotlin_version = '1.2.41'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
classpath 'com.google.gms:google-services:1.5.0-beta2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
Bit annoying but studio acts like it some times. Below steps can fix the issue.
Go to
Settings -> Build, Execution, Development -> Gradle -> Use default gradle wrapper(recommended)
change this to Use local and back to Use default. Studio will ask about updating gradle after closing the settings windows.
I was facing same problem after updation my android studio from 3.0.1 to 3.2.1.My problem was solved after using this.
buildscript {
ext.kotlin_version = '1.2.51'
repositories {
google()
jcenter()
mavenCentral()
maven { url "https://jitpack.io" }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
I had faced this issue on latest Android Studio from Canary channel. You might want to consider downgrading Android Studio to stable version as well.
It happened for me on Android Studio 3.0 RC1.

Categories

Resources