Checking for google play services with firebase [duplicate] - android

Declaring dependencies as
compile 'com.google.firebase:firebase-messaging:9.4.0'
I get "can not resolve symbol GoogleApiAvailability" message in the activity's import row
import com.google.android.gms.common.GoogleApiAvailability;
What is wrong?
not question's duplicate: Google Play Services are already on the latest version

Add this line to your build file dependencies:
compile 'com.google.android.gms:play-services-base:9.4.0'
play-services-base is the Play Services base client library and is listed in the Play Services Setup Guide.

I faced same problem but in my case problem solved by just changing the position of apply plugin: 'com.google.gms.google-services' in the build.gradle(Module: app) file.
Line
apply plugin: 'com.google.gms.google-services'
was written at the last in the gradle file. Remove this from here and add it to the top, below the line apply plugin: 'com.android.application'
Like this:
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
and click on sync now. Problem solved.

For my case just adding this dependency worked -
implementation "com.google.android.gms:play-services-location:16.0.0

If your using the latest classpath 'com.google.gms:google-services:4.3.10', for checking the Google PlayServices Availability you can use GoogleApiAvailabilityLight

Related

Can not Link/Connect Android Studio with Firebase

I have been trying to connect Android studio 4.1 with Firebase but it is not getting linked. I followed the instruction given on the firebase website like copying the dependencies, plugins, etc. into the app Gradle build and Project Gradle Build. My Gradle version is 6.5 and Gradle plugin is 4.1.
The Error shown is:
org.codehaus.groovy.ast.expr.TupleExpression cannot be cast to org.codehaus.groovy.ast.expr.ArgumentListExpression
org.codehaus.groovy.ast.expr.TupleExpression cannot be cast to org.codehaus.groovy.ast.expr.ArgumentListExpression
Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)
Re-download dependencies and sync project (requires network)
The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem.
Stop Gradle build processes (requires restart)
Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project.
In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.
I believe i found the problem.
If you use
apply plugin: 'com.google.gms.google-services'
to your build.gradle(module) like its instructed you get this error.
Instead change apply plugin to id
id 'com.google.gms.google-services'
I haven't finish the app but when I sync, it's successful
Using the Firebase guide to link my app with Firebase, the problem is that you have to scatter the plugins by these 2 ways of implementation:
//First way to implement plugins
plugins {
id 'com.android.application'
id 'kotlin-android'
}
//Second way to implement plugins
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
Taking out the apply plugin ones from the {} of plugins solved my link issues ;)
This Error Rise due to if you are using
apply plugin: 'com.google.gms.google-services'
If You replace apply plugin: with id in build.gradle than this error will be solved.
After change
id 'com.google.gms.google-services'
I do not know how correct this information is, however, I think you should remove the block of code
pugins{
id '...'
}
Instead, start adding code/plugins like:
apply plugin: "com..."
Essentially all the plugins your firebase suggests. It works like magic and you do not have to lose the plugin.
Example Screen Shot
//First way to use Plugin
plugins {
id 'com.android.application'
}
//Second way to use Plugin.
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
I solved my problem by adding:
plugins {
id 'kotlin-kapt'
}
Just Remove Flower Parenthesis mention like this below with out flower brackets
whenever using apply plugins
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'com.google.gms.google-services'

Need help to fix error and add FCM code in my Android app

I am adding Firebase Cloud Messaging.
When I go to add app level gradle code (line as mentioned below) as written on Firbase instructions:
apply plugin: 'com.google.gms.google-services'
I am getting error. Appreciate any help.
Move the apply plugin... statement to after the dependencies block:
dependencies {
...
}
apply plugin: 'com.google.gms.google-services'
Update the version of all play-services-* and firebase-* libraries to at least 9.0.2. The current version is 10.2.1. Be sure to use the same version of all play-services-* and firebase-* libraries.

GooglePlayServicesUtil cannot be resolved

Recent updation to com.google.android.gms:play-services-ads:8.4.0 results in this error. This does not happen when com.google.android.gms:play-services:8.4.0 is used, but it bloats the apk size significantly. Also to implement in-app billing, it is needed to check whether Google Play services are installed or not before starting a purchase.
Is there a workaround for this?
All you need to do in order to use GooglePlayServicesUtil is include the following dependency in your build.gradle:
compile 'com.google.android.gms:play-services-base:10.2.0'
Here you can see all the individual Play Services dependencies that you can pick from:
https://developers.google.com/android/guides/setup#split
I faced same problem but in my case i didn't added any other dependency even my problem solved by just changing the position of apply plugin: 'com.google.gms.google-services' in the build.gradle(Modile: app) file.
Line
apply plugin: 'com.google.gms.google-services'
was written at the last in the gradle file. Remove this from here and add it to the top, below the line apply plugin: 'com.android.application'
Like this:
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
and sync now. Problem solved.

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

Android Studio cannot resolve symbol common

I followed the migration guide from Eclipse to Android Studio carefully and the only error that I am getting is "cannot resolve symbol common" and is happening on these lines:
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GooglePlayServicesUtil;
Does anyone know why this would be happening?
The build tool (gradle) can't find the google_play_services library, that define the relevant classes.
Update your build.gradle file, so that it finds the library (at the right path):
[EDIT 2: since 6.5, you can selectively add needed Google Play Services APIs ]
dependencies {
compile 'com.google.android.gms:play-services-base:9.4.0'
compile 'com.google.android.gms:play-services-XXX:9.4.0'
}
[EDIT: newer method, a 'native' support is now provided]
Open SDK Manager, download and install Google Play Services and Google Repository
Edit build.gradle to add:
dependencies {
compile 'com.google.android.gms:play-services:3.1.36'
}
[Old method]
Check that google-plays-services is a module in your project, and that its build.gradle contains:
dependencies {
compile files('libs/google-play-services.jar')
}
In your module build.gradle:
dependencies {
compile project(':google-play-services')
}
In my case problem solved using other way i.e. apply plugin.
Open your build.gradle(Module: app) file and add this line to the top below the first line.
apply plugin: 'com.google.gms.google-services'
Code looks like:
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
and click on sync now. Problem solved.

Categories

Resources