Error when migrating Crashlytics to Firebase Android - android

I'm basically following the migration guide from within Crashlytics (which is pretty much summarized in this post).
I followed the same instructions verbatim, you can see that from my git diff:
Yet when I sync my Gradle, I get this error:
5:02 PM Gradle sync failed: Could not find method compile() for
arguments [com.google.firebase:firebase-core:11.4.2] on object of type
org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
Update
As mentioned in the comments (and as experienced by us at the end), we shouldn't migrate anyway until further notice:
Update 2
In fabric, if you click on Crashlytics, there is a link on the left nav bar that says Firebase, when you click on it you get this ad

The buildscript block is not a place for your application level dependencies. See this answer for more information on the buildscript block.
You need to place your compile or implementation/api(for gradle 3.4+ and android gradle plugin 3.0+) dependencies into the separate dependencies{} block with the rest of your dependencies, that is usually on the same level as your android plugin configuration.

In your project level grade file, you need to add, maven {
url 'https://maven.fabric.io/public'
} to the repositories.
add the following to your dependencies classpath 'io.fabric.tools:gradle:1.25.1''
In your app level Gradle file put apply plugin: 'io.fabric' below apply plugin: 'com.android.application' and under depencies place this implementation('com.crashlytics.sdk.android:crashlytics:2.7.1#aar') {
transitive = true
}
place apply plugin:'com.google.gms.google-services' at the bottom of the app level gradle file.

Change compile '...' to implementation '...'

You are using Google Services plugin 3.0.0. The instructions for adding the Crashlytics SDK indicate that 3.1.2 or higher is required:
Note: Crashlytics requires Google Services plugin version 3.1.2 or
higher. Check the com.google.gms:google-services version number in
your project's build.gradle dependencies.

Related

Android Crashlytics and Gradle 4.10.1 'varient.getExternalNativeBuildTasks()' warning

Just upgraded to the latest Gradle build and am getting the following warning:
WARNING: API 'variant.getExternalNativeBuildTasks()' is obsolete and has been replaced with 'variant.getExternalNativeBuildProviders()'.
It will be removed at the end of 2019.
I know it's caused by the fabric plugin because removing apply plugin: 'io.fabric' from my app's build.gradle file removes the error when syncing.
Anyone know when fabric will update their plugin to conform to the new Gradle standard or how to manually change the code? I see exactly the problem, but don't know how or if I can change that line of code within fabric myself.
I don't think it's a functional problem yet, but really annoying to see each time I sync the gradle file.
This has been fixed in the 1.28.0 release of the gradle plugin
Users should have this in their top-level build.gradle:
buildscript {
repositories {
// ... repositories, etc. ...
}
dependencies {
// ...other dependencies ...
classpath 'io.fabric.tools:gradle:1.28.0'
}
}
Other details
https://issuetracker.google.com/issues/116408637
https://github.com/firebase/firebase-android-sdk/issues/198#issuecomment-473435453
https://docs.fabric.io/android/changelog.html#march-15-2019

Google Cloud Speech API protobuf is causing 'debugAndroidTestCompile' not found

I have copied and compiled the source code for speech api last month on this location https://github.com/GoogleCloudPlatform/android-docs-samples/tree/master/speech/Speech
and works. Now, when I revisited it, I'm having a Configuration with name 'debugAndroidTestCompile' not found. error.
What is causing this? If you ask me how did I know it is the one, I did the process of elimination. I removed one by one on the gradle file and sync. When I removed apply plugin: 'com.google.protobuf' the error disappears.
Update the protobuf version to the latest in build.gradle. Currently it's 0.8.8, check the latest version from the GitHub repository Protobuf Plugin for Gradle.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.8'
}
}

How to obtain firebase libraries, e.g. firebase-messaging-9.4.0.jar

I am trying to do an automated android build in a local network segment (ie. without access to public jcenter or maven repositories). In order to do that I need to provide all dependencies in a local maven repository which is referenced from the root build.gradle. (NB: if I use the android-maven-plugin instead of gradle the situation is the same).
This works fine, only I have difficulties locating the firebase libraries like firebase-core-9.4.0.jar or firebase-messaging-9.4.0.jar. According to the gradle console output they are searched in a location
<server>/com/google/firebase/firebase-messaging/9.4.0/firebase-messaging-9.4.0.jar
This location does not exist in the public jcenter or maven repositories.
Does anyone know where to find them?
edit: I have observed Android Studio on empty caches using Wireshark (using http for the jcenter repository). The results are rather mysterious. It issues a GET request for
http://jcenter.bintray.com/com/google/firebase/firebase-messaging/9.4.0/firebase-messaging-9.4.0.jar
This request is redirected to
http://repo.jfrog.org/artifactory/libs-release-bintray/com/google/firebase/firebase-messaging/9.4.0/firebase-messaging-9.4.0.jar?referrer
The latter GET request results in HTTP 404 as the repo.jfrog.org repository has no content in the firebase-messaging/ directory. However, Android Studio extracts the jar files in the build directory and continues to build the project.It is unclear, where the jar files come from.
You can show all librarys in the oficial support.
https://firebase.google.com/docs/android/setup
Found this link, hope this help
https://github.com/unity-plugins/Google-Firebase-SDK
According to this, you should add to you build.gradle:
buildscript {
// ...
dependencies {
// ...
classpath 'com.google.gms:google-services:3.1.1'
and that to your app/build.gradle:
apply plugin: 'com.android.application'
android {
// ...
}
dependencies {
// ...
compile 'com.google.firebase:firebase-core:11.8.0'
// Getting a "Could not find" error? Make sure you have
// the latest Google Repository in the Android SDK manager
}
// ADD THIS AT THE BOTTOM
apply plugin: 'com.google.gms.google-services'
Update 2020
Firebase aar are now available on maven repository at https://mvnrepository.com/artifact/com.google.firebase
For example, firebase-core aar is at https://maven.google.com/com/google/firebase/firebase-core/17.4.4/firebase-core-17.4.4.aar

Why do we need to apply google-services plugin AT THE BOTTOM for Firebase SDK?

EDITED
As #doug-stevenson tells us in his answer, the Firebase dependency declaration does not have to be at the bottom of build.gradle anymore.
On the Firebase SDK setup page, it says,
apply plugin: 'com.android.application'
android {
// ...
}
dependencies {
// ...
compile 'com.google.firebase:firebase-core:9.0.2'
}
// ADD THIS AT THE BOTTOM
apply plugin: 'com.google.gms.google-services'
Why is that? Does the ordering matter?
UPDATE: With the latest version of the play services plugin, it is no longer necessary to apply it at the bottom of build.gradle.
It has to do with the way the plugin helps to manage dependencies, and the order of events that Gradle uses to build the project.
The plugin will actually add a dependency on firebase-core if it's not present in your project. It will also check the version of Firebase and Play Services dependencies. However, in order for it to do all this without conflict with other plugins, the Google Services plugin has to run against a project after the project dependencies are already defined. So, applying the plugin after the dependencies block (typically at the bottom of the file) makes all this possible.
The important thing to know is that some projects may experience a version conflict problem if the plugin is at the top. You will avoid these problems by adding it to the bottom.

Found com.google.android.gms:play-services-gcm:8.3.0, but version 8.1.0 is needed

I just updated Google play services to the latest release - 23 - in the Android SDK Manager. Next I updated dependency in my project to:
com.google.android.gms:play-services-gcm:8.3.0
But I got:
Found com.google.android.gms:play-services-gcm:8.3.0, but version 8.1.0 is needed
Found com.google.android.gms:play-services-gcm:8.3.0, but version 8.1.0 is needed
Found com.google.android.gms:play-services-gcm:8.3.0, but version 8.1.0 is needed
Found com.google.android.gms:play-services-gcm:8.3.0, but version 8.1.0 is needed
Found com.google.android.gms:play-services-gcm:8.3.0, but version 8.1.0 is needed
:app:processDebugGoogleServices FAILED
Error:Execution failed for task ':app:processDebugGoogleServices'.
> Please fix the version conflict.
What is wrong? Do you have this problem also?
In your top-level build.gradle file you need to update the dependencies to use
classpath 'com.google.gms:google-services:1.5.0-beta2'
Extra Info:
The latest version of this can be found by looking at the entry on JFrog Bintray
Further Update:
Yes this has been updated since I answered the question. The latest version is:
classpath 'com.google.gms:google-services:3.0.0'
However, it's always worth following the provided link to find the latest version.
Working solution for 8.4.0 (maybe same for previous versions too with this crazy issue)
project build.gradle:
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
classpath 'com.google.gms:google-services:2.1.2'
}
app/mobile build.gradle
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
apply plugin: 'android-apt'
android {
...
...
...
}
dependencies {
// Google Play Services
compile 'com.google.android.gms:play-services-analytics:8.4.0'
// another play services in v8.4.0
}
apply plugin: 'com.google.gms.google-services' // why here on end? Because GOOGLE...
WARNING:
When you move apply plugin: 'com.google.gms.google-services' on top of build gradle, it can not compile...
The Google Play Services guides saved me from this problem
According to the guide,
In versions of Google Play services prior to 6.5, you had to compile the entire package of APIs into your app. In some cases, doing so made it more difficult to keep the number of methods in your app (including framework APIs, library methods, and your own code) under the 65,536 limit.
From version 6.5, you can instead selectively compile Google Play service APIs into your app. For example, to include only the Google Fit and Android Wear APIs, replace the following line in your build.gradle file:
compile 'com.google.android.gms:play-services:8.4.0'
with these lines:
compile 'com.google.android.gms:play-services-fitness:8.4.0'
compile 'com.google.android.gms:play-services-wearable:8.4.0'
I encountered this issue as well, although mine was
Found com.google.android.gms:play-services-gcm:8.4.0, but version
8.3.0 is needed
To fix, I combined Jeff Sutton and mtrakal's answers. I had to make sure I was using the latest Gradle plugin and Google Services versions in the project-level Gradle file (I had Gradle 1.5 and it didn't work):
classpath 'com.google.gms:google-services:2.0.0-beta6'
classpath 'com.android.tools.build:gradle:2.0.0-beta6'
Then I put the apply plugin: 'com.google.gms.google-services' line in the last line of the app Gradle file.
In your top-level build.gradle file you need to change the dependencies to
classpath 'com.google.gms:google-services:+'
I am also getting the same of conflict com.google.android.gms:play-services-gcm:8.3.0 then
I have updated the google playservice tool then it has been resolved
From the SDK manager selected the tool and update now it resolve

Categories

Resources