Failed to resolve firebase-database-15.0.0 - java

I'm currently getting an error on android studio: http://prntscr.com/lebil3
I'm obviously a noob. It has something to do with Firebase, which I connected to my app with some errors, but it did connect successfully.

I checked the link you had given and your implementation looks like this:
implementation 'com.google.firebase:firebase-database:16.0.1:15.0.0'
I think the problem is the last 15.0.0 part. That should not be there. It should be just 16.0.1.
Also try adding this to your app build.gradle:
implementation 'com.google.firebase:firebase-core:16.0.1'
If this doesn't work, in your project level build.gradle file, check if you have:
classpath 'com.google.gms:google-services:4.0.1'
and the plugin at the bottom of your app level build.gradle:
apply plugin: 'com.google.gms.google-services'
If none of this has worked, check out this documentation by Firebase on adding Firebase to your Android app.
Hope this helps!

Please add google() on Project Bluild
allprojects {
repositories {
google()
}
}

Change implementation 'com.google.firebase:firebase-database:16.0.1:15.0.0' to
implementation 'com.google.firebase:firebase-database:16.0.4'. I had the exact same problem a few days back. If that still does not work, compare your other dependencies with mine and adjust accordingly.

Related

Failed to resolve: com.google.android.gms:play-services in IntelliJ Idea with gradle

I'm trying to add google play services to my libGDX project in IntelliJ Idea. I've followed the setup guide here: https://developers.google.com/android/guides/setup
which looks pretty straightforward. I just added those lines to my build.gradle in the corresponding section, so things look now like:
project(":android") {
apply plugin: "android"
apply plugin: 'com.android.application'
configurations { natives }
dependencies {
compile project(":core")
compile "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-arm64-v8a"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86_64"
compile "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-x86"
compile "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-arm64-v8a"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86_64"
compile 'com.google.android.gms:play-services:11.2.0'
}
}
Then I try to sync my gradle project in Idea just to get that "Failed to resolve" error.
Well, the setup guide also says "Be sure you update this version number each time Google Play services is updated", but the problem is that it seems nearly impossible to find that version number: my Google Play Services SDK version according to the Android SDK manager is "43", and so far I have been unable to correlate such "11.2.0" or whatever typical version string with the "43" version number. Not that the setup guide says nothing about that.
Anyway, I have tried a lot of things from the plethora of questions related to this to no avail. Specifically, I have to point out that I do have my Android SDK properly updated and I'm sure it is the one it's being used by Idea (I've already triple-checked this...):
I'm using the API level 26, but anyway the other defines do use the very same directory for the Android SDK. Moreover, I do NOT have any other android SDK installed at all in this laptop, so there's no question about Idea being using that one and that one only.
Any ideas are welcome.
I had the issue when I put jcenter() before google() in project level build.gradle. When I changed the order and put google() before jcenter() in build.gradle the problem disappeared
Here is my final build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
I just replaced version 11.2.0 with 11.0.0 and then it seemed to work fine, so that had to mean that 11.2.0 wasn't included with the latest Android SDK.
So, after struggling with all the available scattered documentation, I reached this document by pure chance (I guess it is not indexed high enough by Google):
https://developers.google.com/android/guides/releases
I quote from there:
Highlights from the Google Play services 11.2 release. Google Play
services dependencies are now available via maven.google.com
Now, even when that shouldn't necessarily mean that they are not available with the downloaded SDK anymore, it seems that this is actually the case.
Anyway, adding google() to my build.gradle didn't work (not found, undefined, or whatever...), so I used a different approach that I found in this document referenced from the previous one:
https://developer.android.com/studio/build/dependencies.html#google-maven
I modified my build.gradle file adding that line to allprojects/repositories, as in:
allprojects {
...
repositories {
...
maven { url "https://maven.google.com/"}
}
}
And then also in the android section in the same build.gradle file:
project(":android") {
...
dependencies {
...
compile 'com.google.android.gms:play-services-ads:11.2.0'
}
}
Those two lines were enough to make Gradle sync without problems. I didn't need to add any plugins apart from the ones that are already added in my libGDX project by default.
After that, I got a few different errors, but none about Gradle or dependencies. In a brief, JFTR:
First, I had a minSdkVersion of 8. Solved by raising it to 14. I think I could live without supporting all those devices below 14.
Second, I had problems with the dex upper limit of references. I've never faced this problem before, but maybe you've already noticed the solution I used: instead of compiling the whole 'com.google.android.gms:play-services' I used only 'com.google.android.gms:play-services-ads' that's the API I'm actually interested right now. For those other particular cases where a solution like this may not be useful, this document could provide some better insight: https://developer.android.com/studio/build/multidex.html
Third, even after that I got this "jumbo" thing problem described and answered here: https://stackoverflow.com/a/26248495/1160360
And that's it. As of now, everything builds and my game does finally shows those Admob banners.
I've spent hours with this, thought, which makes me wonder if all these building automation systems we are using lately are worth the extra load they add.
I mean, the first time I had to add Admob to an app five years ago or so, I just had to download a .jar file and put it on a directory on my project. It was pretty obvious and the whole process, from googling "how to setup Admob in my android project" to have my app showing an Admob banner took me just a few minutes. I'm gonna leave it here, since this is not the place for such kind of debate.
Nonetheless, I hope my own experience is useful for someone else further.
Add this to your project-level build.gradle file:
repositories {
maven {
url "https://maven.google.com"
}
}
It worked for me
I tried solving this problem for hours after I haven't used Android Studio some time and wasn't aware of the updates.
It is important that google() is the first item that stands in repositories like this:
allprojects {
repositories {
google()
jcenter()
mavenCentral()
}
}
Somehow google() was the second item after jcenter(), so everything was messed up and didn't work. Maybe this helps someone.
Google Play services SDK is inside Google Repository.
Start Intellij IDEA.
On the Tools menu, click Android > SDK Manager.
Update the Android SDK Manager: click SDK Tools, expand Support Repository, select Google Repository, and then click OK.
Current Google Repository version is 57.
After update sync your project.
EDIT
From version 11.2.0, we've to use the google maven repo so add google maven repo link in repositories tag. Check release note from here.
allprojects {
..
repositories {
...
maven {
url 'https://maven.google.com'
// Alternative URL is 'https://dl.google.com/dl/android/maven2/'
}
}
}
A more up to date answer:
allprojects {
repositories {
google() // add this
}
}
And don't forget to update gradle to 4.1+ (in gradle-wrapper.properties):
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
source: https://developer.android.com/studio/build/dependencies.html#google-maven
At the latest Google Play Services 15.0.0, it occurs this error when you include entire play service like this
implementation 'com.google.android.gms:play‐services:15.0.0'
Instead, you must specific the detail service like Google Drive
com.google.android.gms:play-services-drive:15.0.0
I have found following solution to replace following code
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
classpath 'com.google.gms:google-services:3.2.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
It's work fine for me
In my case I was using version 17.0.1 .It was showing error.
implementation "com.google.android.gms:play-services-location:17.0.1"
After changing version to 17.0.0, it worked
implementation "com.google.android.gms:play-services-location:17.0.0"
Reason might be I was using maps dependency of version 17.0.0 & location version as 17.0.1.It might have thrown error.So,try to maintain consistency in version numbers.
Check you gradle settings, it may be set to Offline Work
I got this error too but for a different reason. It turns out I had made a typo when I tried to specify the version number as a variable:
dependencies {
// ...
implementation "com.google.android.gms:play-services-location:{$playServices}"
// ...
}
I had defined the variable playServices in gradle.properties in my project's root directory:
playServices=15.0.1
The typo was {$playServices} which should have said ${playServices} like this:
dependencies {
// ...
implementation "com.google.android.gms:play-services-location:${playServices}"
// ...
}
That fixed the problem for me.
I had that problem.
And I found this solve.
In Android Studio, Open File menu, and go to Project Structure, In Module app, go to dependencies tab and you can add 'com.google.android.gms:play-services:x.x.x' by clicking on + button.
this is probably about you don't entered correct dependency version.
you can select correct dependency from this:
file>menu>project structure>app>dependencies>+>Library Dependency>select any thing you need > OK
if cannot find your needs you should update your sdk from below way:
tools>android>sdk manager>sdk update>select any thing you need>ok
step 1:
Open android folder
step 2:
open gradlew.bat file
step 3:
Search this (possible line no 74)
#rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
Step 4:
add --offline add the end like
#rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% --offline

Add Firebase gcm to project

I want to add Firebase to my project to use push notifications
at home I implemented it by adding this line at build.gradle (app)
apply plugin: 'com.google.gms.google-services'
and this line at my build.gradel (project):
classpath 'com.google.gms:google-services:3.0.0'
and it worked .
At work for proxy reasons i'm not able to connect to jcenter and getting this error :
Unknown host 'jcenter.bintray.com'. You may need to adjust the proxy settings in Gradle.
so i cant build the project
I need a way to implement this without the plugin and classpath
I'm using
compileSdkVersion 23
buildToolsVersion "23.0.3"
my depndecies :
dependencies {
compile 'com.google.firebase:firebase-core:9.0.0'
compile 'com.google.firebase:firebase-messaging:9.0.0'
compile 'com.google.android.gms:play-services:9.6.1'
}
And is there a way to add the play-services classes to the gradel cash to be able to work offline
NOTE:
I have tried to update to sdk 24 and build tool 24.0.3
and not use thouse tow lines but i kept geting the error that fire base was never initialized and i need to use this:
firebase.initializeApp(context)
I did use in the application context but did not work
NOTE 2 :
My build.gradel (project) has jcenter as a repository
repositories {
jcenter()
}
Add below code in build.gradle(project)
repositories {
jcenter()
}

How to Configure AdobeCreative SDK for Android gradle build..Correctly

I have just spent hours trying to find out how to configure the AdobeCreative sdk for my android app because I wanted to add photo editing to my application.
The documentation was pretty good but they missed two crucial parts in there documentation which will give plenty of developers headaches. I'm going to answer my question below.
First follow all the documentation from https://creativesdk.adobe.com/docs/android/#/articles/gettingstarted/index.html
However, for your Project gradle.build, the documentation says:
Your Android Studio project contains by default two build.gradle files. In the Project build.gradle file, replace the allprojects block with the following code:
allprojects {
repositories {
jcenter()
maven {
url "${project.rootDir}/creativesdk-repo/release" // Location of the CSDK repo
}
}
}
Be sure to sync your project with the Gradle files after making any edits.
But you should really replace your files with:
allprojects {
apply plugin: 'maven'
repositories {
jcenter()
mavenCentral() //ADD THIS
maven {
url "${project.rootDir}/creativesdk-repo/release"
}
}
}
Notice I added mavenCentral() //ADD THIS.
Without this I received the following errors when doing my gradle build, and I was not able to import any of the classes needed to complete my gradle build:
Error:(38, 13) Failed to resolve: com.adobe.creativesdk.foundation:auth:0.7.329

Integrating moPub into Android Studio

I'm trying to integrate the moPub sdk into my android studio project, but I haven't been able to get the gradle to sync properly. This question has been asked here before, but none of those solutions have worked for me. I followed these instructions, but got the error messages "Plugin with id org.roboelectric not found" and "Unable to load class org.codehaus.groovy.runtime.typehandling.ShortTypeHandling". To fix this, I modified my app's build.gradle with new classpaths:
// 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:0.12.2'
classpath 'org.robolectric:robolectric-gradle-plugin:1.1.0'
classpath 'org.codehaus.groovy:groovy-backports-compat23:2.3.5'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
Unfortunately, I still get the error message "Error:(1, 0) Cause: org/codehaus/groovy/runtime/StringGroovyMethods". I've tried using version 1.0.1 of gradle but nothing changed. I'm not sure where to go from here, so any help would be greatly appreciated.
Read the comment in that build.gradle file.
From this answer https://stackoverflow.com/a/23241888/2278598
<PROJECT_ROOT>\app\build.gradle is specific for app module.
<PROJECT_ROOT>\build.gradle is a "Top-level build file" where you can add configuration options common to all sub-projects/modules.
You need to put the dependencies you are adding in the <PROJECT_ROOT>\app\build.gradle
You have configured Robolectric correctly in the top level gradle file.
You need to use a later version of gradle to build using the Groovy plugin. I would use classpath 'com.android.tools.build:gradle:1.2.3'

Error: Could not find com.google.gms:google-services:1.0. when adding google service plugin in build.gradle in android studio

I am integrating OAuth login for Google+ on my android application, following the tutorial.
According to the tutorial, I should add the Google Service plugin by adding
classpath 'com.google.gms:google-services:1.0' dependency to top-level build.gradle in my android project.
However, when I sync the gradle with the changes, I see the error as follows:
Error:Could not find com.google.gms:google-services:1.0.
Searched in the following locations:
file:/C:/Program Files/Android/Android Studio/gradle/m2repository/com/google/gms/google-services/1.0/google-services-1.0.pom
file:/C:/Program Files/Android/Android Studio/gradle/m2repository/com/google/gms/google-services/1.0/google-services-1.0.jar
https://jcenter.bintray.com/com/google/gms/google-services/1.0/google-services-1.0.pom
https://jcenter.bintray.com/com/google/gms/google-services/1.0/google-services-1.0.jar
In my 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:1.2.3'
classpath 'com.google.gms:google-services:1.0'
}
}
allprojects {
repositories {
jcenter()
}
}
It seems that the android studio is not able to find google-services plugin from repositories.
Does anybody have the same issue? Or, am I missing something?
I ran into the same issue today. In the samples they use this line instead:
classpath 'com.google.gms:google-services:1.3.0-beta1'
This works.
For me I had to switch the repository to jcenter(). I was using mavenCentral and getting this error. As soon as I switched to jcenter() it pulled the dependency down.
To do this, open your build.gradle and replace each instance of mavenCentral() with jcenter()
Google updated their guide. Where it was classpath 'com.google.gms:google-services:1.0' now reads classpath 'com.google.gms:google-services:1.3.0-beta1' like joluet suggested.
Google now released the plugin v1.3.0
I was able to solve it using this:
classpath 'com.google.gms:google-services:1.3.0'
I resolved this issue by doing the following things:
In build.gradle (at project level):
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
mavenCentral()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
classpath 'com.google.gms:google-services:1.5.0-beta2'
}
}
allprojects {
repositories {
mavenCentral()
}
}
In build.gradle (at module level):
On top added:
apply plugin: 'com.google.gms.google-services'
and in dependecies added:
compile 'com.google.android.gms:play-services-analytics:8.3.0'
Apart from this make sure you have updated the Google Play services and Google repository in the SDK.
As of 25th Nov,2015, google released a newer version.
Try adding:
classpath 'com.google.gms:google-services:2.0.0-alpha1'
And don't forget to add jcenter() repository under buildscript.
Thanks.
I think you forgotten gradle's project level,
From developers page:
Add the dependency to your project-level build.gradle
classpath 'com.google.gms:google-services:1.5.0-beta2'
Add the plugin to your app-level build.gradle:
apply plugin: 'com.google.gms.google-services'
Google has updated GCM go check it and for that you have to update your Android Studio too.
I would advise you against doing what you are doing. I did it too (by following Set up a GCM Client App on Android blindly) but ended up with exceeding 65K method limit.
So, you should remove the following lines from your gradle:
apply plugin: 'com.google.gms.google-services'
classpath 'com.google.gms:google-services:1.0'
Now import APIs of Google Plus with simple gradle import:
compile 'com.google.android.gms:play-services-plus:8.1.0'
Adding jcenter repository to project level build.gradle helped in my case:
buildscript {
repositories {
jcenter();
mavenCentral()
}
I was trying to setup firebase for my android app when I faced this problem. Following screenshot should clarify things -
Couple of things I would like to point out -
1. Once you
apply plugin: 'com.google.gms.google-services'
This line should be at the bottom of the app level gradle file. Not sure why but putting at the top did not workout for me.
If you use Android Studio, try to add google service with the IDE.
Right click on folder module.
On left list at Developer Services choose desired service.
Wait for syncing and the IDE will automatically add google dependecies.
add classpath on buildscript
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.google.gms:google-services:1.3.0-beta1'
}
}
You maybe miss this step
Copy the google-services.json file you just downloaded into the app/ or mobile/ directory of your Android Studio project. Open the Android Studio Terminal pane:
$ move path-to-download/google-services.json app/
Have fun.
You need to check the current version as in the link below says, by now:
classpath 'com.google.gms:google-services:1.3.0-beta4'
Check this answer:
Update gradle version
We have to look for the last version in my case was:
dependencies {
classpath 'com.google.gms:google-services:1.4.0-beta3'
}
Here you can find a list of the versions.
I got a similar problem while following the instructions for implementing a GCM client in Android Studio, however, the message I got was :
Error: Could not find com.google.gms:google-services:1.3.0-beta1...
Although I never figured out what was wrong, I simply copied my sources, resources, manifest, and keystore into a new Android Studio project. I then edited the auto-generated gradle build files for the new project by manually re-adding my dependencies.
I made sure not to copy over my build files from the old project verbatim (since the source of the error likely lay in them somewhere).
It is not a satisfying solution, but it worked for me and it took little time.
For me adding this under dependencies worked
compile 'com.google.gms:google-services:3.0.0'
Inside the .idea folder exists a workspace.xml file that defines the project's structure. I suggest you to close Android Studio, then delete .idea folder and then import the project again. The .idea would be generated by the IDE again. For me this solution works.
You should just add classpath 'com.google.gms:google-services:1.3.0-beta1' to dependencies of your (Top level build file) the build.gradle that has the (Project:<name of your project). Hope this helps!
I recently updated to Android Studio 2.3 and somehow apply plugin doesn't work.
After that, I tried various ways and then what work is when I commented out app's build.gradle:
apply plugin: 'com.google.gms.google-services'
and then I add this to top-level build.gradle (below classpath 'com.android.tools.build:gradle:2.2.3'):
classpath 'com.google.gms:google-services:3.0.0'
and then it works.

Categories