GooglePlayServicesUtil cannot be resolved - android

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.

Related

What causes "please check whether the agconnect-services.json file is added to your app project" in using HMS Map Kit with React Native

I already added the agconnect-services.json file and already succeeded in integrating HMS Push Kit in getting AAID and device token
Found it. I added apply plugin: 'com.huawei.agconnect' in /android/app/build.gradle under apply plugin: "com.android.application"
Please note that this configuration must be added to the next line of apply plugin: 'com.android.application' to the app-level build.gradle file. Otherwise, an error may occur.
apply plugin: 'com.huawei.agconnect'

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'

Task :app:uploadCrashlyticsMappingFileRelease FAILED Expected file collection to contain exactly one file, however, it contains no files

I have implemented Firebase crashlytics as suggested. I have put this in my app level release build variant:
firebaseCrashlytics
{
mappingFileUploadEnabled true
}
but when I start to build signed apk I am always getting this error
Task :app:uploadCrashlyticsMappingFileRelease FAILED
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:uploadCrashlyticsMappingFileRelease'.
Expected file collection to contain exactly one file, however, it contains no files.
If I set mappingFileUploadEnabled to false then release apk builds successfully. I have searched a lot but couldn't find a work around. Anyone can help?
Error: "Crashlytics could not find Google Services plugin task: processReleaseGoogleServices. Make sure com.google.gms.google-services is applied BEFORE com.google.firebase.crashlytics. If you are not using the Google Services plugin, you must explicitly declare googleServicesResourceRoot inputs for Crashlytics upload tasks."
I had something like this in build.gradle
apply plugin: 'com.google.firebase.crashlytics'
apply plugin: 'com.google.gms.google-services'
changed it to this and voila! it works:
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'
I faced the same event today.The reason for this to happen is as follows.
If minify true is set, obfuscation will be applied at build time and mapping.txt will be created.
If minify false, it will not be obfuscated at build time and mapping.txt will not be created.
If you set mappingFileUploadEnabled true in the minify false state, the Firebase SDK will try to upload mapping.txt to Firebase even though mapping.txt is not created at build time.
The result is an error.
So, if you set minify false, you have to set mappingFileUploadEnabled false, if you set minify true, you need to set mappingFileUploadEnabled true or false (when mappingFileUploadEnabled false, the crash log on Firebase was obfuscated. It may not make much sense as it will be displayed in state).
Hint
https://firebase.google.com/docs/crashlytics/upgrade-sdk?platform=android#firebase-crashlytics-sdk_7
https://developer.android.com/studio/build/shrink-code#enable
I have resolved this issue by moving the following line from bottom of the page to top in build gradle.
Previous Settings:
apply plugin: 'com.google.gms.google-services'
New Settings:
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'
And the issue is resolved.
In my case I received the error because I wasn't connected to the internet. Fixed it by connecting to the internet and my build release worked perfectly for my Flutter App.
Just change sequence of crashlytics, apply plugin as below :
// Put Google Service
apply plugin: 'com.google.gms.google-services'
// After that the Firebase Crashlytics plugin.
apply plugin: 'com.google.firebase.crashlytics'
Decreasing the version of the following
classpath "com.google.firebase:firebase-crashlytics-gradle:2.8.0"
to 2.6.0 solved my problem.
In my case, it was not adding com.google.gms:google-services at all. The project is in Flutter and Flutter Firebase documents do not mention this.
Add these to android/build.gradle (check the latest versions on the internet):
classpath 'com.google.gms:google-services:4.3.10'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.7.1'
Add these to at the very end of android/app/build.gradle:
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'
For some reason, even if you have generated lib/firebase_options.dart with flutterfire, the plugin still wants google-services.json file you have got from Firebase. Paste that file into android/app/ directory. And it builds for release.
Add this at the bottom of your build.gradle file
apply plugin: 'com.google.gms.google-services'
I have faced several times, and there is a different solution i have.
First of all:
You need to open android module of that project.
Flutter -> Open Android module in Android Studio.
And then go to Gradle Scripts, find gradle.properties (Global properties) and remove this code
systemProp.http.proxyHost=
systemProp.https.proxyHost=
systemProp.https.proxyPort=80
systemProp.http.proxyPort=80
If you're working with GuardSquare's Dexguard solution. Order of your plugins should be,
plugins {
// Google Services Plugin
id 'com.google.gms.google-services'
// Firebase Crashlytics Plugin.
id 'com.google.firebase.crashlytics'
// Dexguard Plugin
id 'dexguard'
}
This way the uploading process of your mapping file is going to succeed.

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.

Checking for google play services with firebase [duplicate]

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

Categories

Resources