I have a Kotlin Android Studio project I am making that integrates with Firebase. I added all the lines required listed in Firebase's instructions into build.gradle for both the Project level and the App level.
But this doesn't include any of the dependencies my project seems to need, I get an error when trying to build and these warnings:
The Declared Dependencies list for my app module only has the two Firebase dependencies, and not any of the dependencies as listed by the above warnings:
I noticed there are some dependencies I assume I need in All Modules:
Is there a way I can add those into my app module folder? I am not sure if that's how it works so let me know.
If this is not the way, please let me know how I can add all these required dependencies quickly onto my Project (preferrably without manually searching each one's repository url and such) so that I can Sync and Build without any errors.
The Gradle Sync was just now successful, here's what happened:
During the editing of the build.gradle files, Google Firebase's instructions were to add this line of code to the Project level's build.gradle file:
buildscript {
repositories {
// Check that you have the following line (if not, add it):
google() // Google's Maven repository
}
dependencies {
...
// Add this line
classpath 'com.google.gms:google-services:4.3.10'
}
}
allprojects {
...
repositories {
// Check that you have the following line (if not, add it):
google() // Google's Maven repository
...
}
}
When Syncing the files through Gradle, an error occurred stating that settings.gradle was prefered to build.gradle, as it also contains repositories and dependencies. The fix was to remove the dependencyResolutionManagement code block in settings.gradle.
Here's what I did to fix all the Sync Warnings and Build errors:
Added the same dependencies found in settings.gradle to build.gradle in the Project level:
gradlePluginPortal()
google()
mavenCentral()
It did not work yet, so then I noticed you also need to add it under the allprojects code block. It will then look something like this:
buildscript {
repositories {
// Check that you have the following line (if not, add it):
gradlePluginPortal()
google() // Google's Maven repository
mavenCentral()
}
dependencies {
...
// Add this line
classpath 'com.google.gms:google-services:4.3.10'
}
}
allprojects {
...
repositories {
// Check that you have the following line (if not, add it):
gradlePluginPortal()
google() // Google's Maven repository
mavenCentral()
...
}
}
And that was all. After that the Gradle Sync took a long time this time and completed successfully without any errors, and the Build worked as well and ran fine as expected.
Related
I am trying to configure a project that uses react-native and google firebase native.
The set up for react-native worked fine, but I ran into a problem with google firebase native.
I followed the instructions at rnfirebase.io.
When I try to sync My project with gradle files from Android Studio, I get the following error:
Build file 'C:\github\flashcards\flashcards\android\app\build.gradle' line: 139
A problem occurred evaluating project ':app'.
> Could not find method plugins() for arguments [build_2psolmxgn6smlx7165ef739cv$_run_closure1$_closure5#1b639892] on extension 'android' of type com.android.build.gradle.internal.dsl.BaseAppModuleExtension.
* Try:
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
...
Here is the relevant portion of my /android/build.gradle file:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
...
repositories {
google()
mavenCentral()
}
dependencies {
classpath("com.android.tools.build:gradle:7.2.1")
classpath("com.facebook.react:react-native-gradle-plugin")
classpath("de.undercouch:gradle-download-task:5.0.1")
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath('com.google.gms:google-services:4.3.14')
}
}
allprojects {
repositories {
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url("$rootDir/../node_modules/react-native/android")
}
maven {
// Android JSC is installed from npm
url("$rootDir/../node_modules/jsc-android/dist")
}
mavenCentral {
// We don't want to fetch react-native from Maven Central as there are
// older versions over there.
content {
excludeGroup "com.facebook.react"
}
}
google()
maven { url 'https://www.jitpack.io' }
}
}
I added the following two lines to the top of my /android/app/build.gradle file:
apply plugin: "com.android.application"
apply plugin: 'com.google.gms.google-services'
Any suggesions for how to fix this problem?
I expected the Sync Project with Gradle files command to complete successfully, but I receive the error described above.
I'm cloning an android course project from GitHub, and facing a series of errors, I've manged to solve some of them till I stuck in last one, the scenario as follows:
1- error: Could not find com.android.support:appcompat-v7:25.1.0. (Solved).
2- error: File google-services.json is missing from module root folder. The Google Services Plugin cannot function without it.(solved)
3-error: Cannot specify -processorpath or --processor-path via CompileOptions.compilerArgs. Use the CompileOptions.annotationProcessorPath property instead.
This one that I can't fixError snip
and after adding this implementation (
implementation 'com.google.firebase:firebase-core:17.4.3'), I get that error as well.
error: This project uses AndroidX dependencies, but the 'android.useAndroidX' property is not enabled. Set this property to true in the gradle.properties file and retry.
Error snip
I've found that link that has exact fix to the errors mentioned in the question.
Cannot specify -processorpath or --processor-path via `CompileOptions.compilerArgs`
solution.
Delete “apply plugin: ‘android-apt’” line from your app module build.gradle file.
(Not necessary to work) Delete “classpath ‘com.neenbedankt.gradle.plugins:android-apt:1.2’” from your top-level build.gradle file.
In “dependencies” section in build.gradle rename
apt ‘net.simonvt.schematic:schematic-compiler:0.6.3’
to
annotationProcessor ‘net.simonvt.schematic:schematic-compiler:0.6.3’
I’m using newest 26.0.2 buildToolsVersion as well as newest support libraries and everything works like a charm.
Remember to use newest gradle (4.1-all for now) and gradle plugin (3.0.0 for now). Add google repository to download newest support libraries. Sync and rebuild project. Now when you go to your manifest file, there should be no more red android:name=".provider.generated.SquawkProvider"
My top-level build.gradle:
// 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:3.0.0’
// Google Services plugin
classpath 'com.google.gms:google-services:3.1.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Let me know if it works.
I was trying to implement the new Firebase-Crashlytics SDK. After going through the document, I got the following error.
Could not find com.google.firebase:firebase-crashlytics-gradle:17.0.0-beta01.
I found the following.
Wrong : com.google.firebase:firebase-crashlytics-gradle:17.0.0-beta01.
Correct : 'com.google.firebase:firebase-crashlytics-gradle:2.0.0-beta01'
To implement the new Firebase Crashlytics SDK you need to add firebase-crashlytics-gradle classpath and firebase-crashlytics dependency.
In your project-level build.gradle file, add the Crashlytics Gradle plugin:
buildscript {
repositories {
// Check that you have Google's Maven repository (if not, add it).
google()
}
dependencies {
// ...
// Check that you have the Google Services Gradle plugin v4.3.2 or later
// (if not, add it).
classpath 'com.google.gms:google-services:4.3.3'
// Add the Crashlytics Gradle plugin.
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.0.0-beta02'
}
}
allprojects {
repositories {
// Check that you have Google's Maven repository (if not, add it).
google()
}
}
In your app-level build.gradle file, apply the Crashlytics Gradle plugin:
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services' // Google Services Gradle plugin
// Apply the Crashlytics Gradle plugin
apply plugin: 'com.google.firebase.crashlytics'
In your app-level build.gradle, add dependencies for Google Analytics and Crashlytics.
dependencies {
// Recommended: Add the Firebase SDK for Google Analytics.
implementation 'com.google.firebase:firebase-analytics:17.2.2'
// Add the Firebase SDK for Crashlytics.
implementation 'com.google.firebase:firebase-crashlytics:17.0.0-beta01'
}
From here.
If you're migrating from Fabric, don't forget to update google-services.json (download it from your Firebase console). It could changed after migration. Migration is described here.
P.S. answer for future strugglers.
Updating these dependencies work for me
dependencies {
classpath 'com.google.gms:google-services:4.3.10'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.0'
}
I am use rnfirebase messaging
And I followed all the steps this links
But this error returns
Could not resolve all dependencies for configuration ':app:_debugApkCopy'.
Could not find com.google.firebase:firebase-messaging:17.1.0.
With the information provided I can't really help but I did suffer from similar kind of issue while I was adding react-native-firebase to one of my projects.
Solution was in project level build.gradle file, move the google() statement in the respositories right to the top, end result looks like below one:
buildscript {
repositories {
google()
jcenter()
maven { url 'https://maven.fabric.io/public'
}
// other things goes here...
}
i developed project in gradle using hadoop and hive dependencies below are the dependencies of project
org.apache.hive:hive-common:1.2.1'
'org.apache.hive:hive-service:1.2.1'
'org.apache.hive:hive-metastore:1.2.1'
'org.apache.derby:derby:10.11.1.1'
'org.apache.hive:hive-jdbc:1.2.1'
but i am facing below error which i am unable to resolve wonderful thing is that if i build the project using maven and added same dependencies in maven project its working fine could you please let me know problem associated with gradle
error:
Could not resolve all dependencies for configuration ':compile'.
> Could not find org.pentaho:pentaho-aggdesigner-algorithm:5.1.5-jhyde.
Searched in the following locations:
https://jcenter.bintray.com/org/pentaho/pentaho-aggdesigner-algorithm/5.1.5-jhyde/pentaho-aggdesigner-algorithm-5.1.5-jhyde.pom
https://jcenter.bintray.com/org/pentaho/pentaho-aggdesigner-algorithm/5.1.5-jhyde/pentaho-aggdesigner-algorithm-5.1.5-jhyde.jar
Required by:
:HiveUnit:unspecified > org.apache.hive:hive-service:1.2.1 > org.apache.hive:hive-exec:1.2.1 > org.apache.calcite:calcite-core:1.2.0-incubating
You need to add the suggested hack in your build.gradle file
repositories {
mavenCentral()
maven {
url "http://conjars.org/repo"
}
}
As hack could be used
repositories {
mavenCentral()
maven {
url "http://conjars.org/repo"
}
}