Is google-service.json now obligatory? - android

Is google-service.json now obligatory ?
In my android app I have added google map and gcm. Now I'm migrating project from eclipse to android studio and I have some little problem.
I have already created a key for gcm, how can I create manually the google-service.json starting from my existing key ?
Another question is :
Initially to add the google play services into my app I followed this official guide :
https://developers.google.com/android/guides/setup
But without this code lines (that I found on stackoverflow):
apply plugin: 'com.google.gms.google-services'
classpath 'com.google.gms:google-services:1.5.0-beta2'
the compiler had not found the play service. Why google doesn't tell nothing about this code line ?

From docs I'd say yes, it's needed. If you follow the line guide you can download a json file even you have already created your project in the developer console. There is a "configuration file" button here. In addition the lines you see "apply plugin" and "classpath" are only for Android Studio (the official IDE). Using the setup suggested it's really easy to setup the project with Android Studio.

Related

Problem with adding Firebase Crashlytics in Xamarin Android project

I have some problem with adding Firebase Crashlytics in Xamarin Android project.
I created an empty android project in visual studio. Then I registered the application in google firebase console. Then downloaded google-services.json and put it in the project.
for this file set the build in googleservicejson mode.
Before that, I added the following nugget packages:
Xamarin.Android.Crashlytics
Xamarin.Android.Crashlytics.Answers
Xamarin.Android.Crashlytics.Beta
Xamarin.Android.Crashlytics.Core
In OnCreate method, I added the following code:
Fabric.Fabric.With (this, new Crashlytics.Crashlytics ());
Crashlytics.Crashlytics.HandleManagedExceptions ();
Also I add this meta data in AndroidManifest.xml
<meta-data android:name="io.fabric.ApiKey" android:value="firebase api key" />
Then I added this in strings.xml
<string name="com.crashlytics.android.home.firebaseandroid">33</string>
where home.firebaseandroid is my apk name
After cleaning and rebuild, when I launch the application it throw this exception:
Fabric.Services.Concurrency.UnmetDependencyException: 'This app relies on Crashlytics. Please sign up for access at https://fabric.io/sign_up,
install an Android build tool and ask a team member to invite you to this app's organization.'
As I understand, the application is looking for an api key for the Fabric, but I only have the api key from firebase.
Has anyone had a same problem?
Advise in what direction to look, please.
Thanks in advance.
If you're using a google services file, then you should not be specifying API keys in your AndroidManifest. The google services file already contains the API key that Crashlytics SDK is looking for.
If you want to try something else, see my comment on this issue here: https://github.com/xamarin/XamarinComponents/issues/760#issuecomment-579010612
This is the workaround I've found at that time (yes, I know it is not the last version, please keep reading):
I've fixed the issue at least for me. It seems that the issue was caused by
dependency interactions.
For anybody struggling with this, I've got it working by using exactly
the following versions:
Xamarin.Android.Crashlytics 2.9.4.1
Xamarin.Android.Crashlytics.Answers 1.4.2
Xamarin.Android.Crashlytics.Beta 1.2.9
Xamarin.Android.Crashlytics.Core 2.6.3 Xamarin.Android.Fabric 1.4.3
Xamarin.Build.Download 0.4.11
Installing Crashlytics will install Xamarin.Build.Download 0.7.1 as a
dependency, but (at least for me) it is not possible to get a proper
build anymore with that version. So this package should be downgraded
after it is installed.
Having said that; you must be aware of the imminent deprecation of this Crashlytics version based on Fabric, right?
All of us were received a mail from Google informing that:
We are writing to let you know that the Fabric Crashlytics SDK is now deprecated and will continue reporting your app's crashes until
November 15, 2020. After this date, the Fabric Crashlytics SDK and
beta versions of the Firebase Crashlytics SDK will stop sending crash
reports for your app.What happened?
We are replacing Fabric Crashlytics SDKs and beta versions of the Firebase Crashlytics SDKs with the generally available Firebase
Crashlytics SDKs.What's Next?
To continue getting crash reports in the Firebase console, make sure to upgrade your apps to the Firebase Crashlytics SDK versions
17.0.0+ for Android, 4.0.0+ for iOS, and 6.15.0+ for Unity before November 15, 2020.Android
So everything is going to change soon, and you shouldn't use the Fabric solution anymore, especially for new projects.
You can found the new official nuget package here, but it is a preview (the xamarin team is working on this, I guess, but they are dangerously near the deadline -as we all):
https://www.nuget.org/packages/Xamarin.Firebase.Crashlytics/117.0.0-preview02
This is the official repository issue to add comments:
https://github.com/xamarin/XamarinComponents/issues/956
I'm currently migrating my project to this new Crashlytics version, and one thing to keep in mind is that you need to use AndroidX (that was a problem for me, I'm working on an old project's maintenance, and the migration to AndroidX is not ready yet)
When you'll add this new package and the google-services.json you will need to change the following in your old code:
Every CrashLytics.Crashlytics reference will be just FirebaseCrashlytics.
No initialization is needed, you can get the FirebaseCrashlytics.Instance anywhere
To log an exception you will need to use the RecordException method instead of the old LogException
SetUserIdentifier is changed to SetUserId, and SetUserName is no longer there
There is no method to crash on purpose anymore, so now you have to simply throw any exception you want if you wanna test your implementation
Maybe I'm missing something, but basically, that's all.

Unity android plugin for FCM

I'm trying to add Google FCM push notification function to Unity project. I'm surprised that there are no resources about Google FCM for Unity. There are only old Google GCM resources. This is my step-by-step progress below.
Make Android Studio project and register it to a FCM console project
Add google-service.json to '/app' and configure build.gradle (project and module)
Add MyFirebaseInstanceIDService, MyFirebaseMessagingService java classes and onTokenRefresh, sendRegistrationToServer, onMessageReceived, sendNotification methods according to sample example in FCM document
Add services for the classes to AndroidManifest.xml
After that, I tested the Android Studio project on mobile, and FCM console push notification works well. Then, I started to configure the Android Studio project for Unity.
Change 'application' to 'library' in build.gradle (module) and add deleteOldJar, exportJar for AndroidPlugin.jar
Add classes.jar of Unity to Android Studio library and module setting
Remove 'android:icon ...', 'android:theme ...' in AndroidManifest.xml
Export jar and add AndroidPlugin.jar, AndroidManifest.xml to 'Plugins/Android' in Unity
Then, I tested the Unity project on mobile. It is built without exception, but FCM console push notification didn't work. (I made test log for confirming that the Android Studio libray is well plugined for Unity, the log worked well)
Maybe, there are somethings to add to 'Plugins/Android' except AndroidManifest.xml and AndroidPlugin.jar like references below.
Google firebase analytics plugin for unity - StackOverflow
http://joxi.ru/Q2KeQD7C3zdYrj
But, I couldn't find my answer. Please let me know what I have to do or add.
Sorry for bad english and long explanation. Many thanks :)
I used Unity SDK in OneSignal.
It is very simple, easy, and cool SDK for push notification.
Reference link below.
https://onesignal.com/
This approach will not be feasible.
Jar files do not contain resources, and as such, the json file will be missing from the jar build. Alternatively, aar files, which would in theory contain the resources, are interpreted by Unity3D as pure plugin and ignores the resources or at least some, specially when using gradle. But Unity is getting better at it.
Try https://firebase.google.com/docs/unity/setup. It's new and I got the sample project to work already.
Just to add: the new Plugin of Firebase for Unity3D worked liked a charm. Use cases like pure system try notification don't need a single line of additional programming on the client side. Data Messages are very easily implemented as well.

Unable to build Android app FabricGenerateResourcesDebug

I'm trying to integrate twitter's sdk with my app. I'm following this guide.
Unfortunately, when I try to build my project, I keep receiving this error:
Error:Execution failed for task ':app:fabricGenerateResourcesDebug'.
Crashlytics Developer Tools error.
Unfortunately because I don't have 10 reputation, I can't post my build.gradle file because it has links in it. Just trust the fact that it looks just like the build.gradle example in the top link provided.
Is there something that I'm missing that I may have overlooked?
Your problem should be caused due to that you did not create a “crashlytics.properties” file which is required to contain API Key and Build Secret in your app directory.
The solution is quite simple that you don't even have to manually setup anything on your original project. Just following this link:
https://fabric.io/settings/organizations
It will lead you to the Fabric official website, which helps you to download and install Fabric plugins into your IDE (Android Studio, IntelliJ or Eclipse). This might be a new magical method to integrate twitter's SDK within your app, it will automatically configure your project. You will see the magic when you get there.
Hope it helps.
The fix I found is that I did not place the meta-data tag with the API Key INSIDE the application tag in the androidmanifest.xml.

Can't get the google_play_services_version value after setting the google services API

I've set the Google play services API on my android app project, I did as I saw in the documentation for google android developer. I started by copying the google library services in the folder of my project, then I added the refernce in the build (like we see in the photo the gooogle play services lib is perfectly deployed) and then I tried to copy this piece of code in android but manifiest not recognize the second line. android:value="#integer/google_play_services_version"
So any help for that please ! Thanks
Xavier is right, there are no resources in the GooglePlayServices JAR file you usually get your compiled classes.
As you're in Android Studio you can just add to your gradle dependencies : compile 'com.google.android.gms:play-services:5.2.08'

What are the dependencies of Google Maps v2?

I am new to Android and want to embed Google Maps v2 to my application, but can anyone please tell me which dependencies should I install on phone or include to project?
Include Gradle dependency:
dependencies {
implementation 'com.google.android.gms:play-services-maps:16.1.0'
}
You may found Gradle, please helpful. Also, check out this page for Android APIs releases.
I assume you have already read https://developers.google.com/maps/documentation/android/ :-)
In short:
you need to download and install the Google Play service lib via SDK manager
create a project in Eclipse via "Create project from existing source code" and use the source code from "\android-sdk\extras\google\google_play_services\libproject\google-play-services_lib"
add this project as dependency to your actual project via right click on your project -> properties -> android -> add project library
add the permissions as described in the link mentioned above
request an API key as pointed out in the link above as well
add a SupportedMapFragment to your layout
you need an active Google account on the device to will test your map (it will install the required dependencies on the device automatically then)
That's it :-)
Hope that helps....

Categories

Resources