Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android:required="false" is being ignored in uses-feature tag

Tags:

android

Following is from AndroidManifest.xml file.

<permission
    android:name="com.kivi.kividoctors.permission.C2D_MESSAGE"
    android:protectionLevel="signature" />

<uses-feature android:name="android.hardware.camera" android:required="false" />
<uses-feature android:name="android.hardware.telephony" android:required="false" />
<uses-feature android:name="android.hardware.camera.autofocus" android:required="false" />
<uses-feature android:name="android.hardware.camera.flash" android:required="false" />

But Google keep showing me following 3 features in a list when I update the Application. It just ignore the android:required property for camera's features. Where as it works for telephony feature.

android.hardware.CAMERA
android.hardware.camera.AUTOFOCUS
android.hardware.camera.FLASH

I've tried all the possible ways I could find on SO, but couldn't find the solution.

Is there anything I'm missing to get rid of above 3 features from the list?


Update:

Also tried capitalizing feature in android:name property like this.
(I know this is not right, but still I tried and no luck with that too)

<uses-feature android:name="android.hardware.CAMERA" android:required="false" />
<uses-feature android:name="android.hardware.camera.AUTOFOCUS" android:required="false" />
<uses-feature android:name="android.hardware.camera.FLASH" android:required="false" />
like image 433
Alok Patel Avatar asked Jun 15 '16 10:06

Alok Patel


1 Answers

Apparently, a library had <uses-feature> for these and marked them as required. If any contributor to the manifest marks a feature as required, it winds up as required in the final merged manifest.

When you encounter this, first, try to identify what library (or libraries) are doing this. The manifest merger report (should be in build/output/logs/ of your app module) is clunky to read but should point out who the culprits are.

Next, add tools:replace="required" to the <uses-feature> elements in your manifest, to indicate that you want to overrule any lower-priority manifests, such as those from libraries.

Finally, be very careful about using the libraries that you identified earlier. They are expecting features that you explicitly are not requiring. Using those libraries on devices where those features are not being met is risky.

like image 200
CommonsWare Avatar answered Oct 15 '22 14:10

CommonsWare