I want to initialize firebase at runtime. I convert the JSON file to XML on this site -> https://dandar3.github.io/android/google-services-json-to-xml.html
Then I put string in app/res/strings.xml file.
app/build.gradle file:
apply plugin: 'io.fabric'
.....
dependencies {
implementation 'com.crashlytics.sdk.android:crashlytics:2.9.6'
implementation 'com.google.firebase:firebase-core:16.0.4'
}
build.gradle file:
buildscript {
repositories {
...
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
...
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'io.fabric.tools:gradle:1.26.1'
}
}
I build my project and the error is here:
Crashlytics found an invalid API key: null.
Check the Crashlytics plugin to make sure that the application has been added successfully!
Contact support#fabric.io for assistance.
What is the problem? Firebase says .that you can delete the google_services.json file from your project.
Related
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've been working with firebase to access an activity on my project. Everything works fine, no compilation errors. However after i go to tools > firebase i can connect to my app easily, however when i try to click Add Real time database it shows me this:
build.gradle will include these new dependencies:
compile 'com.google.firebase:firebase-database:16.0.1:15.0.0'
Since compile is deprecated i use implementation, and when i do
Implementation 'com.google.firebase:firebase-database:16.0.1:15.0.0'
i get the following error Failed to resolve: firebase-database-15.0.0
and my sync fails.
Change Root Gradle to
buildscript {
// ...
dependencies {
// ...
classpath 'com.google.gms:google-services:4.0.1' // google-services plugin
}
}
allprojects {
// ...
repositories {
// ...
google() // Google's Maven repository
}
}
And App Gradle To
apply plugin: 'com.android.application'
android {
// ...
}
dependencies {
// ...
implementation 'com.google.firebase:firebase-core:16.0.1'
implementation 'com.google.firebase:firebase-database:16.0.1'
// 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'
Hope This May Help You
add jcenter() in your project-level gradle.
allprojects {
repositories {
google()
jcenter()
}
}
and keep remaining as #Tomin B said.
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'm trying a sample code which implements Google Cloud Messaging (GCM) and that is provided by google itself, GCM Demo.
I don't know how exactly I can add the dependencies
List item
Add the dependency to your project's top-level build.gradle:
When I go to Project Structure > Modules > Add and then select Module Dependency then a pop up screen appears for no module found to depend on.
If there is another way I can add the dependencies then a help would be appreciated.I have attached an image regarding the same.
As described in the link.
Add the dependency to your project's top-level build.gradle: (just edit the file)
classpath 'com.google.gms:google-services:1.3.0-beta1'
You should have somenthing like this:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
classpath 'com.google.gms:google-services:1.3.0-beta1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
Then add the plugin to your app-level build.gradle (just edit the file):
apply plugin: 'com.google.gms.google-services'
You should have somenthing like this:
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
//..
}
Finally add the dependency in your app-level build.gradle
dependencies {
compile "com.google.android.gms:play-services:7.5.0"
}
I am trying to add google play services library in Android studio.I have added the google play services in build.gradle.
But it is now working for me.I have referred many SO Post regarding to this.But it doesn't solved my problem.
Below I am posted the build.gradle code where I have added the google play services.
build.gradle:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
apply plugin : 'android'
dependencies {
compile 'com.google.android.gms:play-services:4.0.30'
}
allprojects {
repositories {
jcenter()
}
}
}
While adding the google play services in dependencies at gradle compile com.google.android.gms:play-services:4.0.30. I am getting an error:plugin with id not working.
Anyone can help me with this.Thank you.
The build.gradle you have posted seems to be the project configuration. The global project build.gradle has the buildscript tag and also the comment about not adding application dependencies as can be seen in your question.
There should be another build.gradle inside your app module where you should also find something similar to this depending on your version of Android Studio and Gradle,
apply plugin: 'com.android.application'
android {
...
}
dependencies {
...
}
Place your compile 'com.google.android.gms:play-services:4.0.30' inside the app module's build.gradle depedencies
Use latest version of play services:
compile 'com.google.android.gms:play-services:7.5.0'
Update:
Think you using wrong gradle file. You must add the above code in the gardle file under app folder.
Please add your library dependencies in the build.gradle file the resides inside your app module
apply plugin: 'com.android.application'
repositories {
maven { url "http://dl.bintray.com/populov/maven" }
mavenCentral()
}
android {
...............
}
dependencies {
compile 'com.google.android.gms:play-services:4.0.30'
}
You should not add these dependencies inside build.gradle file for the root folder
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
Do not place your application dependencies inside the outer build.gradle file they belongin the individual module build.gradle files