It has been quite a few months since I had time to work on my app. And today I downloaded latest Android Studio and SDK, I found a problem after I built the app.
My AndroidManifest file does NOT require any permissions on GET_ACCOUNTS or USE_CREDENTIALS, however they are shown as new added permissions when I tried to upload the app in Google Play store. I did use Google Play Games service in the game, but it was not like this before I did this update.
Does anybody know why? I Googled a while but could not find any clue..
If you recently updated, check to see if you switched to Google Play services 7.5 with a line in your build.gradle file such as
compile 'com.google.android.gms:play-services:7.5.0'
Google Play services 7.5 automatically adds required permissions - when you use com.google.android.gms:play-services - that says you are using every part of Google Play services, potentially adding more permissions than you intended.
Instead, you should selectively include what APIs you use by using separate dependencies such as:
compile 'com.google.android.gms:play-services-games:7.5.0'
compile 'com.google.android.gms:play-services-drive:7.5.0'
(Assuming you'd need Drive for Saved Games support)
Related
I want to check out the new Awareness API which is quite new. I’m using Play Services 9.0.2. The documentation has this example:
GoogleApiClient client = new GoogleApiClient.Builder(context)
.addApi(Awareness.API)
.build();
client.connect();
However, there is no hint which dependency needs to been added. Any idea?
I found it out: I need to upgrade to PlayServices 9.2.0 and the dependency is hidden in play-services-contextmanager. Just add those dependencies and here we go:
compile 'com.google.android.gms:play-services-awareness:10.2.4'
Please use the latest play services library, at the time I updated this answer it was 10.2.4
If you want to know the latest Dependency you can use my web tool called DependencyLookup.
Keep in mind that this library was added in the Play Services Repository v31. Make sure that you have at least that version installed in the SDK manager.
You need to add the library of Google Play services to your project.
Set up Google Play services
To access the Awareness API, your app's development project must
include Google Play services. Download and install the Google Play
services component via the SDK Manager and add the library to your
project. For details, see the Android guide to setting up Google Play
services.
Source
Set up Google Play services
To access the Awareness API, your app's development project must include Google Play services. Download and install the Google Play services component via the SDK Manager and add the library to your project. For details, see the Android guide to setting up Google Play services.
which is apparently on the same page you got your code sample from here
Most of the times the number of method references in your app exceeds the 65K limit, your app may fail to compile. So in order to mitigate this problem when compiling your app ,specify only the specific Google Play services APIs your app uses, instead of all of them.
compile 'com.google.android.gms:play-services-basement:9.2.0'
compile 'com.google.android.gms:play-services-contextmanager:9.2.0'
You will find the complete solution here:
http://xordroid.com/create-intelligent-apps-with-google-awareness-api/
Starting PlayServices v9.6.0, contextmanager has been changed to awareness
So, the previous answers won't be working.
The correct dependencies, as of v10.2.4 are
compile 'com.google.android.gms:play-services-basement:10.2.0'
compile 'com.google.android.gms:play-services-awareness:10.2.0'
I have an app that have only had minor changes the last couple of years. Yesterday I released a bugfix to Google Play, and noticed that my app suddenly requires 5 new permissions:
android.permission.ACCESS_COARSE_LOCATION
android.permission.GET_ACCOUNTS
android.permission.READ_EXTERNAL_STORAGE maxSdkVersion=18
android.permission.USE_CREDENTIALS
android.permission.WRITE_EXTERNAL_STORAGE
I have not made any changes to AndroidManifest.xml, so these 5 permissions are not listed there.
I'm using Google's billing library (com.android.billing) for in-app purchases. This might have been automatically updated by Android Studio.
I have upgraded these libraries as well:
com.android.support:appcompat-v7:22.1.1 -> 22.2.0
com.android.support:support-v4:22.1.1 -> 22.2.0
com.google.android.gms:play-services:7.3.0 -> 7.5.0
Does anyone know why this happened?
UPDATE WITH ANSWER
#ahmad-nawaz is right, and his answer led me to figure this out. Here is a more detailed answer to my question:
The library that wanted the extra permissions is Google Play Services.
In Google Play Services version 6.5 and onward, you can (and probably should) define which specific API you need, instead of just importing the whole package.
In my case, I was just using play-services-analytics, so I changed this in my build.gradle
compile 'com.google.android.gms:play-services:7.5.0'
to this
compile 'com.google.android.gms:play-services-analytics:7.5.0'
After this change, all the 5 permissions mentioned in the original question disappeared.
Here is the complete list of the individual APIs of Google Play Services: https://developers.google.com/android/guides/setup#split
These are coming from Libraries you used. Android studio merge the libraries permissions into app.
I am building a google maps app on android using android studio
When I released the first version of my app, no one was able to view the google maps as google play services must be installed on the devices by users ( I cant ask people to download that in each device) so I want to embed it into my app.
I have been searching for 4 days and no luck so far
I got that google-play-services.jar library can be added to the app and by that no need for the user to install play services
I am not sure if I should use google-play-services.jar or com.google.android.gms:play-services in my android studio app.
I read in other answers that I can use google-play-services.jar into my app so I can get Google Play Services ready without the need for user to install it.
in another said that com.google.android.gms:play-services is a must in the app!
Anyway has experience in this?
Please advice.
Thanks
google-play-services.jar will only interract with installed play services on the smartphone. You can't emmbed the play service application in your apk, there's nos sense.
For peoples who want to use your application, they need to download it by the play store or maybe they already have google music or google maps on their phone, so they have play services installed.
So just add google play services in your gradle file
compile 'com.google.android.gms:play-services:(version)'
What are the recommended practices for maintaining the widest backwards compatibility of an Android app while depending on Google Play Services?
The developer implementation documentation for using Android Studio indicate compiling against v5.+
compile 'com.google.android.gms:play-services:5.+' which with the available downloads I'm using seem to end up using version 5208000. At which point I get errors and warnings returned while testing an application:
W/GooglePlayServicesUtil Google Play services out of date. Requires 5208000 but found 5089036
E/GooglePlayServicesUtil GooglePlayServices not available due to error 2
Admob, my dependency on Google Play Services, appears to work normally however. If you follow the Google recommendation to call isGooglePlayServicesAvailable() and GooglePlayServicesUtil.getErrorDialog(), the user is told an upgrade is required for the app to work and sent to the store where there is no update available.
In other places maintaining backwards compatibility means compiling against the oldest API version that supports the features you need. So I tried with v4 compile 'com.google.android.gms:play-services:4.+' which generated another error:
E/GooglePlayServicesUtil﹕ The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.
Searching around indicates this is a false report and can be ignored.
If I compile against a newer API version and it's not present on the device will things work? Or do I have to coax users into upgrading? Is it better to compile against an older API version and assume that things are properly backwards compatible with newer versions running on devices?
I'm the developer of an SDK that optionally depends on Google Play Services, and my approach has been, as you mentioned, to compile against the oldest version of Google Play Services that contains the APIs that I need, such that downstream clients won't into issues like these.
If the APIs that you need are available in v4, it's safe to compile against com.google.android.gms:play-services:4.+, and to follow Google's directions to show a prompt to a user to upgrade. Users will only see the upgrade dialog if they're running an older version of v4, or if they're somehow still on v3. In either case, the upgrade dialog should correctly lead them to the Play Store, where there will indeed be an upgrade available.
If the APIs that you need are only available in v5, do not use a wildcard version (ie 5.+). You should compile against an older version that is likely to be widespread, such as com.google.android.gms:play-services:5.0.89. Using a wildcard means you'll compile against the very latest version of Google Play Services that you've installed in the Android SDK manager, on whatever computer/environment you happen to be compiling on, which to me just feels wrong - I don't care if it's Google building the library, I like to know exactly what I'm compiling into my app.
Moreover, with a wildcard, if you always keep your SDK manager updated, whenever you compile the release version of your app and then push it to Google Play, you may have just shipped an app against a version of Play Services that isn't widespread, or worse - isn't even available for download on every device yet, in which case users will get the dialog and not be able to upgrade, as you've seen during development.
i am using google play services in my project, i am trying to use google map v2 service in my app.
For this i included play services as dependency in build.gradle file as mentioned in this thread.
for now the latest version of play services is 3.2.65 and i am pointing to it. Ok.
So my question is ,In the future when google releases newer version of play services and the device has play services version above 3.2.65 which was specified in build.gradle file, will cause any problem or not? And will my application adapts the latest feature of play services automatically or i have to release updates of my application every time google releases newer version of play services.
And if not then is there any other way or including play services in module dependency so that my application will always use updated version of play services.
Thanks
My guess is you have to recompile your project with a newer version of the library.
Various library versions are downloaded on your machine and used to compile the project.
SDK_DIRECTORY/extras/google/m2repository/com/google/android/gms
Of course Google releases things in order to preserve compatibility, so if you don't need any new feature/API you don't have to update your project.
In your build.gradle file, you can also write in this way:
compile 'com.google.android.gms:play-services:3.1.+'
So you will pick up any new 3.1.x version whatever is the latest number.
In the future when google releases newer version of play services and the device has play services version above 3.2.65 which was specified in build.gradle file, will cause any problem or not?
No, it won't cause any problems. Google Maps Android API v2 is developed in a forward-compatible way. No change will ever be made that can break older apps.
And will my application adapts the latest feature of play services automatically or i have to release updates of my application every time google releases newer version of play services.
Depends. Most of the bug fixes are made in the Google Play Services app and you don't need to update client library. Because client library has almost no code, there is low chance any bug will appear there.
If you want to use new features, you will obviously have to update the library to be able to call new APIs.