I have a working Android app using:
Google Maps (play-services-maps)
Google Location, Activity Recognition, and Places (play-services-location)
Google Analytics (play-services-analytics)
Google Mobile Ads (play-services-ads)
I'm currently using version 8.3.0, everything works fine. I'd like to upgrade to the last version, 9.2.0. When I change the number in the gradle files, Android Studio is unable to find the APIs packages & classes (saying "package XXX does not exist" and "Cannot find symbol class YYY").
I currently have no google-services.json file, do I need it now? I tried without success, probably because I have several modules / submodules, and I don't know where the json file is needed or not.
The problem is that I need a package name to create the JSON file, and I have some library modules, without package name, using Google APIs.
If needed, here is the project structure:
Maybe you did something wrong while upgrading your project. Make sure you follow the correct steps in upgrading. I suggest you to retry the process of upgrading, but make sure you do the correct way. Like in configuring your build and setting up Google play service.
For your question about google-services.json, Google-services.json contains developer credentials and configuration settings, which is needed to verify while connecting with GoogleApiClient. Though your service is working fine without it. But it will only work with your test device, as it is detecting your developer account. And after you releae your app in public, it will not work without the json file. So you need it and don't delete.
sources: What does google-services.json really do?
So, I finally got it: I was using the AutocompletePrediction.getDescription() method, which has simply been removed (and replaced by AutocompletePrediction.getDescription .getFullText()). That call made gradle stops building -_- .
Thanks Google for removing stuff without deprecating it for a while (though the docs says that the method is deprecated: https://developers.google.com/places/android-api/releases)...
I can also confirm that in my case, the google-service.json file is NOT required.
Related
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.
I just imported a project from Eclipse to AS. In the project I'm using Google Maps, and in Eclipse I had these lines in the manifest:
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY">
Importing the project left these lines. Do I still need them in the manifest now when using Gradle or can I just add this line to gradle.build and thats it?
compile 'com.google.android.gms:play-services:9.4.0'
Short answer- you need both!
Explanation (if you require it)
The Gradle lines basically tell Gradle to pull in the library called 'com.google.android.gms:play-services' and the version '9.4.0'. This is just a bunch of code you'll want to include in your project. (It's a lot of code, when your project looks bigger you'll want to split that out into just the components you use)
Meta data is used for different things than Gradle dependencies are- specifically in your case, you are using it here to:
supply your google api key, and,
supply your google play services version number
NOTE: hide your API key!!!! (just google "why should I hide my api key")
The version number is the version that your app expects to use, which you might specify if you are working on an older version, or for a workaround. Typically, these fields are just used to show maps.
The API key is used to access your Web Console app client for your app- i.e., the app on Google API Console that you linked to your Android Studio app. This is not something you want publically exposed on Stack Overflow.
Hope that helps :)
I am trying to get the basic Google Maps example to work
https://developers.google.com/maps/documentation/android-api/start
Unfortunately, whenever I run it on the emulator using Geny, the screen is blank. After some searching, I am seeing others say that I should verify that both the app/src/debug/google_maps_api.xml and app/src/release/google_maps_api.xml have the key I created.
I have verified that app/src/main/res/values/google_maps_pi.xml has the key, but the other directories for debug and release do not exist.
I have synced my project with gradle files and still not seeing them.
Any ideas would be appreciated.
If you are adding Google maps to an existing project, using this tutorial as a basis,
https://developers.google.com/maps/documentation/android-api/start
then you must first create a new project using the maps activity wizard in Android Studio. Copy and paste the various differences mentioned in the tutorial such as the manifest.xml, build.gradle, and google_maps_api.xml.
The one thing I did not realize I needed to do was copy the directories app/src/debug and app/src/release from the new project to my existing one.
Once that is done then you can confirm that app/src/res/values/google_maps_pi.xml and app/src/res/release/google_maps_api.xml are using the same API you created.
I have been working with Java for about a couple of months now and I have been stuck introducing Google API into my Maps app. I need some help with these imports.
Here is what I did: I was following the code of a Places API demo which I can link if needed. I ended up having to add some libraries. Before I did, I was getting errors from all of the imports that started with com.google.api.client...etc. Then once I added all of these libraries, I then got left with 2 errors out of my imports.
The errors are: the "com.google.api.client.googleapis.GoogleHeaders" and "com.google.api.client.http.json.JsonHttpParser". I am receiving them both as "cannot be resolved to a type". These errors are causing some more errors throughout the rest of my code. I was hoping someone can help me solve this. I know it should have something to do with my code, but I am not sure what is going on. I know I am missing something.
Also, I installed the Google Plugin to install the APIs and when I did, I added the "Google + API" and the "GoogleOAuth2" APIs and that is where I am stuck at. Please someone help.
Here is the screenshot: Full Screenshot
I haven't worked with Maps, but as I understand it Maps is now packaged with Google Play Services, which I have been working with recently.
Firstly, the installation of Google Play Services is well-documented and you should look at this (if you haven't done so already):
http://developer.android.com/google/play-services/setup.html
There are a few areas that cause difficulty, and one is the section "Set Up a Project with the Library". There are different possible approaches but I suggest you take the following steps.
Ensure that the Google Play Services lib (and any other libs) are defined as library projects (Properties ...Android.. Library ...IsLibrary) and that they have no errors (cleaning may not be sufficient - you may have to shut down Eclipse to remove the errors).
When the library projects are error free, add them to your project. The normal way of doing this is to REFERENCE them (check what the documentation says) but you do this by (Properties ...Android.. Library ...Add).
Then check out (Properties ... Java Build Path ...) - read the documentation but you need your libs in here.
Then clean your project but note that a restart of Eclipse may be necessary to remove the errors from your project.
There are other errors that can arise - another common one arises if you have different versions of the v4 support lib in your libs / project and you get a message "...this check is based on SHA1 at this time". This is well documented on Stack Overflow.
Good luck !
I created one android application I followed all the steps to make API keys and intalled google play services from Android SDK Manager. I read so many blogs for integartion google map, I Import the libraty project to my worksapce from "\adt-bundle-windows-x86\sdk\extras\google\google_play_services\libproject\google-play-services_lib" path. when I tried to add library project from project's property window in android tab I got following out put
But when I check this library second time than I got following out put in android tab
I have proble of libraty project. I used eclipse IDE. I got some solution but for different IDE , so suggest me for best solution..
The first problem usually happens when the path to the library is too long, the solution would be to move the google-play-services lib to a place where it path would be shorter and then try to reference it again.
your second problem:
"Google Maps Android API(23127): Failed to load map. Could not contact Google servers."
caused usually when there is a problem with your API key or a problem with the permissions you have defined in the manifest file, take a look a this post I wrote and go over all the steps to generate the key:
Google Map API key
Next, check steps 5-7 and verify you defined the right permissions:
Google Map API V2
Sometimes it may happen, you should remove and add the same library again
or restart the eclipse and add the library