Unnecessary steps on the google official guide on App Invites - android

I finally managed to get google app invites working in my app. I enabled them on the developer console and followed this guide. The following steps were giving me problems:
Add the dependency to your project's top-level build.gradle:
classpath 'com.google.gms:google-services:1.3.0-beta1'
Add the plugin to your app-level build.gradle:
apply plugin: 'com.google.gms.google-services'
Copy the google-services.json file you just downloaded into the app/ or mobile/ directory of your Android Studio project.
By adding that classpath I had to use jcenter as my repository, as this package isn't available at mavenCentral. However, even if I built the project with jcenter as a repository, the gradle build failed with an empty error message. I tried to debug the problem but the stacktrace for the crash was enormous.
My solution was to simply ignore these steps. The app invites are working flawlessly since then.
With this in mind, here goes my question. Why were all these steps listed on the official google guide if they are not necessary? Am I missing something here?

When I started official sample for Invite API yesterday, I had problem but just because of version of google-services (1st step -> add the dependency of your project's top-level build.gradle), so I have to change it to the latest version:
classpath 'com.android.tools.build:gradle:1.3.0-beta4'
classpath 'com.google.gms:google-services:1.3.0-beta4'
and this solves all problems. I don't understand your question, which step you exactly skipped of these 3 steps mentioned and made invite api functional?

Finally found the answer. The service was working on my prototype because it doesn't check for credentials on the test device. Once released to public, the keys are needed for the service to work correctly as Ituoke Ajanlekoko said in the comments.
Further information can be found at this topic:
What does google-services.json really do?

Related

I am facing issues compiling my project in Android Studio due to gradle

I have been trying to compile an app in Android Studio and it was working fine until I tried to add mobile ads.
Information about AS:
Android Studio Electric Eeel | 2022.1.1 Patch 1
Build #AI-221.6008.13.2211.9514443, built on January 21, 2023
I am following this article from Google Devs: https://developers.google.com/admob/android/quick-start#kotlin
I have read many questions and answers here on stackoverflow and also forums and blogs. The majority are from 2016-2021 and I understand a lot has changed since then...
According to the article, I have to include Google's Maven repository and Maven central repository in both my buildscript and allprojects sections on project-level build.gradle file.
My project-level build gradle contains a plugins { } section and when I paste the code form the article I get an error message saying that buldscript { } should be before plugins { }.
So I change that only to receive an error message saying "Build was configured to prefer settings repositories over project repositories but repository 'Google' was added by build file 'build.gradle'".
Following the article, I enter my module build.gradle file to add dependencies and I also update the AndroidManifest.xml with the information provided (I also have my actual AdMob ID).
I am also updating my MainActivity.kt file to include the necessary entries to preload Google Mobile Ads SDK.
But I am not able to compile anything anymore. I tried to move the buildscript{} and allprojects{} parts to the module build.gradle (within the app folder) but then I get following error:
A problem occurred evaluating project ':app'.
Could not find method android() for arguments [build_l8adkk1ea3ur5qn0u7k2w4gx$_run_closure1#20be5c4a] on project ':app' of type org.gradle.api.Project.
I have updated gradle to the latest version through Android Studio.
I have the latest version of Android Studio.
I have also specified the minSDK and targetSDK according to the article.
Not sure what to do or what the problem is. And all the solutions provided in various blogs/forums and here on stackoverflow seem outdated.
Thank you in advance

Firebase Crashlytics Invalid Key Error

I want to integrate Firebase Crashlytics into my Android game (developed using Cocos2D-X engine).
I have followed the steps mentioned in this link.
I'm getting following error when building the project using Android Studio:
ERROR - Crashlytics Developer Tools error.
java.lang.IllegalArgumentException: Crashlytics found an invalid API key: null.
Check the Crashlytics plugin to make sure that the application has been added successfully!
It looks like that I am missing some API key. How can I find the Crashlytics API key in Firebase? How to mention that key in the Android project?
I would appreciate any suggestions and thought on this topic. Thank you.
Rolling back to "com.google.gms:google-services:4.0.1" in my project build.gradle file fixed the problem for me.
The Firebase docs say to use version 4.1.0, which if you follow will give the error above.
Please note the following things, this should solve your issue:
Check Android Studio version, suggested version is 3.1.4.
Classpath (project-level build.gradle file shouldn't have any alpha or beta versions. That is because Firebase only supports stable version of Android Studio.
That said, the recommended setup of your gradle version is:
classpath 'com.android.tools.build:gradle:3.1.4'
classpath 'com.google.gms:google-services:4.1.0'
Firebase Crashlytics requires the Google services Gradle plugin (com.google.gms:google-services) in your build script to process the google-services.json file at build time. However, Crashlytics does work on devices that do not have Google Play services.
I have added this line at end of build.gradle
apply plugin: 'com.google.gms.google-services'

Firebase cloud messaging in cordova app

Am new to cordova, I have created a cordova app and run successfully, now I need to integrate a push notification in it. So i gone with google Firebase, i have created all the dependencies for firebase and downloaded google.services.json . And i have added listener in index.js file (refered this link) also, no problem upto this. In the firebase Document, asked to add these lines at app level build grade
compile 'com.google.firebase:firebase-core:11.8.0'
apply plugin: 'com.google.gms.google-services'
and this at buildscript classpath 'com.google.gms:google-services:3.0.0'
After adding this am using command cordova build android , it throws error. Am not sure what is wrong
Note :
Also tried without adding the above line, in that case, build gets success but the notification is not working.
You can refer to the official phonegap plugin here. This would give you a fair idea on how to do or alternatively if it meets your use case you can directly use it.
Cordova is a free version of phone-gap so compatibility will not be an issue.

Google-services.json not found

I am facing this error
Error:Execution failed for task ':app:processDebugGoogleServices'.
File google-services.json is missing. The Google Services Plugin cannot
function without it.
Searched Location:
C:\Users\Kartik\AndroidStudioProjects\barcode\app\src\debug\google-
services.json
C:\Users\Kartik\AndroidStudioProjects\barcode\app\google-services.json
I have added this path in build.gradle(project:barcode)
classpath 'com.android.tools.build:gradle:2.1.2'
classpath 'com.google.gms:google-services:3.0.0'
and added this in build.gradle(Module:app)
apply plugin: 'com.google.gms.google-services'
I have also added the google-services.json file in project->app folder but then also it is giving the same error.
i faced the same problem before .
check the json file name and make sure that there is no additional spaces
First of all please make sure that you have followed documentation for firebase and not google developers guidelines and alspo generated Google-services.json for firebase project that is running in your firebase-console, you can see all your running projects in your dashboard in firebase
Make sure you have correct json file, this problem is describe here.
You can follow these steps also as per firebase documentaion.
still if you are all correct and getting errors make sure you have updated play services version in your SDK and also put this line in your app module build.gradle file, to make sure that multidex is unable. Hope you will make something out of it.
defaultConfig {
multiDexEnabled true
}

Android Marshmallow error:GoogleService failed to initialize, status: 10, Missing an expected resource: [duplicate]

I am using google Maps in my android application. I have created the key and added necessary permissions in manifest file. But soon I start the application I get this message in debugger:
GoogleService failed to initialize, status: 10, Missing an expected
resource: 'R.string.google_app_id' for initializing Google services.
Possible causes are missing google-services.json or
com.google.gms.google-services gradle plugin.
I am not sure whats wrong. The Map is working fine and I can use it without any issues. My gradle file has this entry:
compile 'com.google.android.gms:play-services:8.4.0'
What is it complaining about and how do I alleviate it?
[From Product Manager # Google]
You can fix this issue by downloading and copying the google-services.json file for your Android app by following the steps below:
Select your app/project name and Android packagename from this link and click Continue to Choose and configure services.
Click Continue to Generate Configuration files.
Download google-services.json and copy the file to the app/ or mobile/ module directory in your Android project.
If you have previously imported your Google project into Firebase, you can
get the updated google-services.json from the Firebase console under Project Settings.
DO NOT COPY the PROJECT_NUMBER as suggested by one of the other answers since the google_app_id refers to your app within a Project and not the project itself.
You need to place the configuration file (google-services.json) generated by developer.google.com, as mentioned in the 2nd step of the official docs here
The process is simple
You can select your project or create a new one.
Then after selecting desired services (in this case the maps service), you can generate the configuration file.
For people who have migrated to the Firebase projects they can get the same by going to Firebase Console, selecting your project and under settings you will find the configuration file.
Then as quoted in step 3 of the official docs here
Copy the google-services.json file you just downloaded into the app/ or mobile/ directory of your Android
P.S : For people downvoting this answer, please do leave a comment as to why you are down voting it.
In my case, the cause of this error was that the Google Services plugin for Gradle and the Play Services library were incompatible versions. Instructions for compatible versions:
1) Add the dependency to your project-level build.gradle:
classpath 'com.google.gms:google-services:1.5.0-beta2'
2) Add the plugin to your app-level build.gradle:
apply plugin: 'com.google.gms.google-services'
3) If you're using Android Studio, this is the string to add to the dependency section of your application's build.gradle file:
dependencies {
compile "com.google.android.gms:play-services:8.3.0"
}
Source: https://developers.google.com/cloud-messaging/android/client
I met the same problem and solved it followed the official solution.
Here are the steps:
get the configuration file google-services.json from this link.
Copy the google-services.json file you just downloaded into the app/ or mobile/ directory of your Android Studio project.
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'
Add this dependency to your app-level build.gradle:
dependencies {
compile "com.google.android.gms:play-services:8.3.0"
}
For those who face this problem even after correctly setting up play services and placing google-services.json file in project/app folder, the actual solution is to
Build > Rebuild Project
Possibly due to the fact that strings from json file are not integrated into compiled resources until a full rebuild is performed.
For Xamarin/Visual Studio Mac I needed to add this to the bottom of my Droid.csproj
<Target Name="ProcessGoogleServicesJson" Condition=" '#(GoogleServicesJson)' != '' AND '$(AndroidApplication)' == 'True' AND '$(DesignTimeBuild)' != 'True'" BeforeTargets="$(ProcessGoogleServicesJsonBeforeTargets)" AfterTargets="$(ProcessGoogleServicesJsonAfterTargets)">
<Message Text="Using ProcessGoogleServicesJson override" Importance="high" />
<ProcessGoogleServicesJson GoogleServicesJsons="#(GoogleServicesJson)" IntermediateOutputPath="$(IntermediateOutputPath)" MonoAndroidResDirIntermediate="$(MonoAndroidResDirIntermediate)" AndroidPackageName="$(_AndroidPackage)">
<Output ItemName="_AndroidResourceDest" TaskParameter="GoogleServicesGeneratedResources" />
<Output ItemName="FileWrites" TaskParameter="GoogleServicesGeneratedResources" />
</ProcessGoogleServicesJson>
<ItemGroup>
<FileWrites Include="$(IntermediateOutputPath)\ProcessGoogleServicesJson.stamp" />
</ItemGroup>
https://github.com/xamarin/GooglePlayServicesComponents/issues/64
This also happen to me. In my case, it is because Android studio tried to insert some code to my main activity. Removing the code fixes the error
Inserted code is about App Indexing:
https://developers.google.com/app-indexing/android/publish
I had the same issue back then. Was able to solve it by using only the necessary play services library, which in my case GCM.
Instead of com.google.android.gms:play-services:8.4.0, I use com.google.android.gms:play-services-gcm:8.4.0. See here for more info; this also solves multidex problem.
Then I applied both #Radix and #Alexander's approach to remove the message GCM has been output in the logcat regarding the google-services.json.
You can change the versionCode and versionName of your app in your Gradle file.
A quick fix I used is to disable signing. If you aren't wanting to create production code you can set your build variant to debug, localOldDebug or localDebug.
Click on Build Variants on the bottom left in Android Studio.
how-to-disable-generated-signed-apk-android-studio
Just have another solution i'm remove accidentally
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
Add this and work, is for new solution

Categories

Resources