Removing <uses-feature> doesn't remove it from for Google Play - android

I am developing an app for Android, and, after uploading it to Google Play, I realised that I was not depending on a <uses-feature> anymore, so I removed it. To be more specific, I was coding a Camera Activity, so I needed these features:
android.hardware.CAMERA
android.hardware.camera.AUTOFOCUS
However, after that, I decided to go for the Camera Intent. That's why I removed them.
My surprise comes when I see that the APK Information modal shows that it is still using those features, even if they aren't in my Manifest.
My question is, does that mean that I will "need" those features, even if I removed them? Maybe because they are depending on the Camera Intent?

I "figured it out". When you add a android:required="false" to the <uses-feature>, it becomes unnecessary and is removed from the APK information.

Your Application uses those feature because you added <uses-permission> in your code.
Whenever you specify permission it access all the features until you uniquely not specify which features you exactly want to use in your application.

Related

Why we need to use <uses-feature> attribute?

My question is related to camera. When an application needs to use the system camera, we create an intent with ACTION_IMAGE_CAPTURE action and add a permission like this in the manifest file.
<uses-permission android:name="android.permission.CAMERA"/>
But besides that, there is one such
<uses-feature android:name="android.hardware.camera"/>
What is it for? I read that if this line is written, then if the phone does not have a camera the application will not install. Is it true? And besides this, why do we need this?
And for what the line <uses-feature/> is generally responsible in manifest file?
<uses-feature android:name="android.hardware.camera"/>
above line will use to check the device have camera hardware.
When you upload an app on play store they will filter your app based on the feature for the specific device,
if any device will search your app on play store and that device doesn't have camera hardware then they will not be allowed to install an app on that device.
but if your requirement is to force download the app if the device doesn't have camara hardware the you can use :
<uses-feature android:name="android.hardware.camera" android:required="false"/>
the android:required = "false" will allow you to install
hope you understand
Google documentation for <uses-feature> itself clearly states:
Google Play uses the <uses-feature> elements declared in your app
manifest to filter your app from devices that do not meet its hardware
and software feature requirements.
By specifying the features that your application requires, you enable
Google Play to present your application only to users whose devices
meet the application's feature requirements, rather than presenting it
to all users.
Some permissions in Android are connected to some hardware/software features of a device, like CAMERA. Since every Android device in the market differs in its hardware and software configuration, there's a greater possibility that some feature that you're trying to add in your app doesn't support all Android Devices. If you try to use the camera in a camera-less device (a superficial assumption), then your app will not behave as you expect.
In short, if you want your app to only be available for the set of devices having that particular capability, then you can add <uses-feature> tag inside the manifest with the desired capability.
This is just for filtering apps in Play Store based on device configuration and support.
You can define zero or more <uses-feature> capabilities based on your need.
Note: If you don't want your app to get filtered out just for the sake of a feature that doesn't impact the overall user experience of the app, you can smartly disable the particular feature if it's not available in your app.
For that, you have to write
<uses-feature android:name="YOUR_NON_COMPULSORY_FEATURE" android:required="false" />
For example, if your app uses CAMERA feature, but your app is not dependent on that feature, you can disable just the CAMERA feature to provide a non-buggy user experience.
<uses-feature/> is there to guide Google play store to filter out this application from devices which do not have Camera hardware.
As a developer - lets ask this Question to ourself with respect to your app.
What will user do with my app whose phone does not have Camera?
If the answer to Above is "Not much" - then what is the point allowing user to install your app on phone if user can't do much with it? It is waste of time & Internet bandwidth for the user.
Also if user is really frustrated by eventually learning that this app is not much of use, they may RATE your app poorly on Play Store.
Hence its there is <uses-feature/> option to protect both developers & users from above scenario.
This is very important part. Let suppose your application uses a particular hard ware and that is essential for your app that hardware must be available on a device to use your application. If that is defined, your app will be filtered out for those devices that have that specific hard ware.
NOTE: As it is well documented over Google Developer site
**Google Play uses the elements declared in your app manifest to filter your app from devices that do not meet its hardware and software feature requirements.
By specifying the features that your application requires, you enable Google Play to present your application only to users whose devices meet the application's feature requirements, rather than presenting it to all users.**
Refer this link for further reference guide

android:what's the differences between the "required" in use-feature and the "requiredFeature" in user-permission?

There is the use-permission and use-feature like below:
<uses-permission android:name="android.permission.CAMERA" android:requiredFeature="false"/>
<uses-feature android:name="android.hardware.camera" android:required="false"/>
I am just not quite clear about the "android:requiredFeature" attribute. Is it the same effect as the "android:required" in use-feature?
I just cannot find the android:requiredFeature related infomation in the android developer site and google....
Yes more or less both have the same effect. android:requiredFeature is only used in API level 26 and higher if your app has minSdkVersion less than 26 the application will simply ignore the attribute.
<uses-permission> generally is used to specify a permission that a user must grant for the app to run correctly, it is not necessarily used to filter the app for devices on Google Play. If you want your app to be filtered for devices based on the hardware feature your app uses, the recommended way is to define <uses-feature> element in your manifest.
As mentioned in the other answer, based on <uses-permission> Google play can assume that your app requires the underlying hardware feature and it can filter your app based on that, but its not always true, your app might work without that hardware feature but it prefers to have that feature, So to avoid filtering based on <uses-permission>, android:requiredFeature attribute is used to enhance your control over the filtering.
I think this is the main cause of the difference, which is not really a difference but a more efficient case of managing what do you want the app store to do with your app.
In some cases, the permissions that you request through
can affect how your application is filtered by
Google Play.
If you request a hardware-related permission — CAMERA, for example —
Google Play assumes that your application requires the underlying
hardware feature and filters the application from devices that do not
offer it.
To control filtering, always explicitly declare hardware features in
elements, rather than relying on Google Play to
"discover" the requirements in elements. Then, if
you want to disable filtering for a particular feature, you can add a
android:required="false" attribute to the declaration.
For a list of permissions that imply hardware features, see the
documentation for the element.
from: Android developers

ACTION_IMAGE_CAPTURE and CAMERA feature

I'm using ACTION_IMAGE_CAPTURE to request camera app to take a photo.
According to official doc if my app uses camera feature but doesn't require it for correct functioning, following should be left in manifest
<manifest ... >
<uses-feature android:name="android.hardware.camera"
android:required="false" />
...
</manifest>
I don't really get what is the idea of having those lines in manifest, isn't it just the same without having this not required feature.
I would like to know what is the point to write this ? Can I safely skip this from manifest ?
Doesn't matter if I have the feature listed in manifest, I'll still be able to check it during run-time, correct hasSystemFeature(PackageManager.FEATURE_CAMERA) ?
No, it's not the same. As the docs say:
The element offers a required attribute that lets you specify whether your application requires and cannot function without the declared feature, or whether it prefers to have the feature but can function without it.
This means that it would be nice to have that feature, but the app will still work without it. For example, an app that can take pictures but that does not need it as part of its normal operation would use the required=false for the camera.
You might ask that through code, yes. But the problem is that some permissions imply that you require some particular hardware:
If an application requests hardware-related permissions, Google Play assumes that the application uses the underlying hardware features and therefore requires those features, even though there might be no corresponding to declarations. For such permissions, Google Play adds the underlying hardware features to the metadata that it stores for the application and sets up filters for them.
For example, if an application requests the CAMERA permission but does not declare a element for android.hardware.camera, Google Play considers that the application requires a camera and should not be shown to users whose devices do not offer a camera.
So if you want to use some features but not others, and you are including the permission, you might want to declare that your app does not really requires the presence of a certain device feature.
From Android docs:
The purpose of a declaration is to inform any external
entity of the set of hardware and software features on which your
application depends.
In general, you should always make sure to declare
elements for all of the features that your application requires
<uses-feature android:name="android.hardware.camera"
android:required="false" />
If required = "false" is given in manifest then app uses a camera but it’s not mandatory for the application to work, and all device can install app from play store whether device has camera feature or not.
if required = "true" is given in manifest then device which has camera feature can only use app other devices which do not have camera feature not able to install from google play store.
This allows Google Play Store to filter out apps for devices that don’t have their required features.
I hope it helps!

How to check the compatible screens for an Android application?

I want my Android app not to be visible in the Play Store to people using a tablet.
I've made the changes to the AndroidManifest that were described in the documentation, and I'm sure it'll work, but I cannot update the apk unless I'm a 100% sure that it does.
The thing is, there is apparently no other way to check than to update the current production version...
Is there anyway I could make sure my compatible-screen setting works well, without any disturbance for the application users ?
Have you taken a look at the compatible screens documentation?
They have this little excerpt here that may be helpful:
The Android system does not read the manifest element (neither at install-time nor at runtime). This element is informational only and may be used by external services (such as Google Play) to better understand the application's compatibility with specific screen configurations and enable filtering for users. Any screen configuration that is not declared in this element is a screen with which the application is not compatible. Thus, external services (such as Google Play) should not provide the application to devices with such screens.
Does that help?

Remove specific hardware request from Android app

In my app I use Camera object to turn flashlight on. However, I do check if there's flashlight, and if there isn't, I don't use make any calls to Camera object. However, there's still an automatic requirement added to manifest - android.hardware.camera.
How can I remove it? I can guarantee that there will be no calls to Camera if there's no camera.
Use the <uses-feature> along with <uses-permission> attribute in the Manifest for features that are used in the app but not extremely required.
For e.g here,
<uses-feature android:name="android.hardware.camera" android:required="false"/>
By explicitly specifying the android:required attribute as false, the app can work in devices with no Camera
From the documentation page
If a feature is explicitly declared as not being required, Google Play
does not add the feature to the list of required features. For that
reason, an explicitly declared non-required feature is never
considered when filtering the application. Even if the device does not
provide the declared feature, Google Play will still consider the
application compatible with the device and will show it to the user,
unless other filtering rules apply.
Like Google Play filters app, if a hardware feature is provided with explicitly declared as not required, the app can work in devices with no Camera support

Categories

Resources