I am trying to add fabric to my project but there is no where to provide the api key or secret on fabric.io?
Is this ok?
apply plugin: 'io.fabric'
`Please add maven and dependencies in project-level build.gradle
buildscript {
repositories {
// ...
// Add repository
maven {
url 'https://maven.fabric.io/public'
}
}
dependencies {
// ...
// Check for v3.1.2 or higher
classpath 'com.google.gms.google-services:4.2.0'
// Add dependency
classpath 'io.fabric.tools:gradle:1.28.1'
}
}
allprojects {
// ...
repositories {
// ...
// Check that you have the following line (if not, add it):
google() // Google's Maven repository
// ...
}
}
In your app-level build.gradle,add plugin and dependencies :
apply plugin: 'io.fabric'
dependencies {
// ...
// Check for v11.4.2 or higher
implementation 'com.google.firebase:firebase-core:16.0.8'
// Add dependency
implementation 'com.crashlytics.sdk.android:crashlytics:2.10.0'
}
Follow below link https://firebase.google.com/docs/crashlytics/get-started?platform=android . Add your project into Firebase Console.
Related
I just updated Android Studio and started a new project. But now the project grade file seems different.
Here are the lines:
plugins {
id 'com.android.application' version '7.1.0' apply false
id 'com.android.library' version '7.1.0' apply false
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Now, for example, I need to paste the Firebase lines in the project level Gradle file. Where should I do it?
Here's the Firebase code:
buildscript {
repositories {
google() // Google's Maven repository
}
dependencies {
classpath 'com.google.gms:google-services:4.3.10'
}
}
allprojects {
repositories {
google() // Google's Maven repository
}
}
In all of my previous projects, the Gradle structure was also like that. Now I'm a little confused about what to do.
But now the project grade file seems different.
Yes, starting with the new Bumblebee update of Android Studio, the build.gradle (Project) file is changed. In order to be able to use Google Services, you have to add to your build.gradle (Project) file the following lines:
plugins {
id 'com.android.application' version '7.1.0' apply false
id 'com.android.library' version '7.1.0' apply false
id 'com.google.gms.google-services' version '4.3.0' apply false 👈
}
task clean(type: Delete) {
delete rootProject.buildDir
}
And inside your build.gradle (Module) file, the following plugin IDs:
plugins {
id 'com.android.application'
id 'com.google.gms.google-services' 👈
}
In this way, your Firebase services will finally work.
P.S. Not 100% sure if the Firebase Assistant is updated with these new Android Studio changes.
Edit 2022-14-07:
Here is a repo that uses this new structure:
https://github.com/alexmamo/FirestoreCleanArchitectureApp
Edit:
There is nothing changed regarding the way you add dependencies in the build.gradle (Module) file. If for example, you want to add Firestore and Glide, please use:
dependencies {
//Regular dependecies
implementation platform("com.google.firebase:firebase-bom:29.0.4")
implementation "com.google.firebase:firebase-firestore"
implementation "com.github.bumptech.glide:glide:4.12.0"
}
Edit2:
With the new updates, you don't need to worry about adding any lines under the repositories { }. That was a requirement in the previous versions.
I've had the same problem just add in the gradle.build project
id 'com.google.gms.google-services' version '4.3.0' apply false
and then add in gradle.build module
dependencies {
//Regular dependecies
implementation platform("com.google.firebase:firebase-bom:30.4.0")
implementation "com.google.firebase:firebase-firestore"
}
You will find your classpath from https://console.firebase.google.com/
You will find something like this in the firebase(if you already got your classpath then you can ignore this section)
buildscript {
repositories {
// Make sure that you have the following two repositories
google() // Google's Maven repository
mavenCentral() // Maven Central repository
}
dependencies {
...
// Add the dependency for the Google services Gradle plugin
classpath 'com.google.gms:google-services:4.3.13'
}
}
allprojects {
...
repositories {
// Make sure that you have the following two repositories
google() // Google's Maven repository
mavenCentral() // Maven Central repository
}
}
just copy the classpath
1)In build.gradle(project)
before plugins make these changes-->
buildscript {
dependencies {
classpath 'com.google.gms:google-services:4.3.13'
}
}
plugins {
id 'com.android.application' version '7.2.2' apply false
id 'com.android.library' version '7.2.2' apply false
}
task clean(type: Delete) {
delete rootProject.buildDir
}
2)In build.gradle(module) add these lines in pulgins and dependencies section
plugins {
id 'com.android.application'
id 'com.google.gms.google-services'
}
dependencies {
implementation platform('com.google.firebase:firebase-bom:30.2.0')
implementation 'com.google.firebase:firebase-analytics'
}
In the section adding the gradle plugin for this React Native component, it tells me to add the following code to app/build.gradle:
buildscript {
repositories {
maven { url 'https://plugins.gradle.org/m2/' } // Gradle Plugin Portal
}
dependencies {
classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.12.1, 0.99.99]'
}
}
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
However, I've added other components that said to add similar code. For example, this component says to add this code:
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
// The Fabric Gradle plugin uses an open ended version to react
// quickly to Android tooling updates
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
What I Want To Know:
How do you add the code for both of these components into the same project?
You should have one build script and add all the repositories in the repositories block and the dependences in the dependencies block
it should be like this
buildscript {
repositories {
maven { url 'https://plugins.gradle.org/m2/' } // Gradle Plugin Portal
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.12.1, 0.99.99]'
// The Fabric Gradle plugin uses an open ended version to react
// quickly to Android tooling updates
classpath 'io.fabric.tools:gradle:1.+'
}
}
for the apply plugins should be in the build.gradle for the app module
add them on the top
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
apply plugin: 'io.fabric'
android {
compileSdkVersion 28
defaultConfig {
applicationId "your.app.package"
}
}
I want to use Segment (with Firebase) into my NativeScript app. So I must follow this instructions : https://segment.com/docs/destinations/firebase but I must modify two files : the Module-level build.gradle :
buildscript {
dependencies {
// Add these lines
compile 'com.segment.analytics.android:analytics:4.+'
compile 'com.segment.analytics.android.integrations:firebase:+'
}
}
// Add to the bottom of the file
apply plugin: 'com.google.gms.google-services'
and the Project-level build.gradle :
buildscript {
dependencies {
// Add this line
classpath 'com.google.gms:google-services:3.1.0'
}
}
allprojects {
repositories {
// Add this line
maven { url 'https://maven.google.com' }
}
}
But with NativeScript I have only one build.gradle. So, how can I implement this lines in gradle ?
Thanks !
I know this question is old but they may help someone in the future. Nativescript Docs aren't the best and this worked for me so it MAY not work for you.
This applies for Plugins and Regular Apps.
Buildscript Gradle.
App_Resources/Android/buildscript.gradle
PLUGINS buildscript.gradle
repositories {
// Add this line
maven { url 'https://maven.google.com' }
}
dependencies {
classpath 'com.google.gms:google-services:3.1.0'
}
App Grade
PLUGINS include.gradle
App_Resources/Android/app.gradle
dependencies {
compile 'com.segment.analytics.android:analytics:4.+'
compile 'com.segment.analytics.android.integrations:firebase:+'
}
apply plugin: 'com.google.gms.google-services'
HOWEVER
The compile configuration still exists but should not be used as it will not offer the guarantees that the api and implementation configurations provide.https://docs.gradle.org/current/userguide/java_library_plugin.html
You can also write this as
App Grade
PLUGINS include.gradle
App_Resources/Android/app.gradle
dependencies {
implementation 'com.segment.analytics.android:analytics:4.+'
implementation 'com.segment.analytics.android.integrations:firebase:+'
}
I still have this error inspite of me adding
compile 'com.google.android.gms:play-services-auth:11.8.0'
compile "com.google.android.gms:play-services-gcm:11.8.0" to the build.gradle(app).Please help me resolve this problem.
First, add rules to your root-level build.gradle file, to include the google-services plugin and the Google's Maven repository:
buildscript {
// ...
dependencies {
// ...
classpath 'com.google.gms:google-services:3.2.0' // google-services
plugin
}
}
allprojects {
// ...
repositories {
// ...
maven {
url "https://maven.google.com" // Google's Maven repository
}
}
}
Then, in your module Gradle file (usually the app/build.gradle), add the
apply plugin line at the bottom of the file to enable the Gradle plugin:
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
// added the Google maven respository to your root build.gradle
}
// ADD THIS AT THE BOTTOM
apply plugin: 'com.google.gms.google-services'
You may need to make sure that your activity is importing the Firebase Auth module.
In the .java file for your activity (eg. Login.java):
import com.google.firebase.auth.FirebaseAuth;
I added the following the in my project's build.gradle file:
Buildscript {
repositories {
jcenter()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.14.3'
}
I addded this in the AndroidManifest.xml file:
<meta-data
android:name="io.fabric.ApiKey"
android:value="apiKeyValue"/>
I added this in the build.gradle(app) file:
apply plugin: 'io.fabric'
And the following dependency:
compile('com.crashlytics.sdk.android:crashlytics:2.6.7#aar') {
transitive = true;
}
After all this, why does not resolve the Crashlytics dependency?
Upgrade your dependencies like so:
Buildscript {
repositories {
jcenter()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
//classpath 'io.fabric.tools:gradle:1.14.3' upgrade to the lastest version for compatibility
classpath 'io.fabric.tools:gradle:1.22.1'
}
And add the following in the build.gradle (app) file:
repositories {
maven { url 'https://maven.fabric.io/public' }
}
It is recommended to use 1.+ for the Fabric plugin dependency to use the latest version rather than specifying a specific version:
classpath 'io.fabric.tools:gradle:1.+'
There are detailed instructions on how to integrate Crashlytics into Android studio here.
Crashlytics Fabric.io deprecated.
use Firebase Crashlytics.