5

in my AndroidManifest.xml file, I have these 2 lines:

<uses-permission                        android:name="android.permission.CAMERA" />
<uses-feature android:required="false"  android:name="android.hardware.camera" />

But then when I upload to Google Play, it indicates that the camera is required. And if i use the aapt tool, it shows: "uses-feature: name='android.hardware.camera'"

Does anyone know why it is ignoring my code and requiring the device to have a camera?

Edit: Here's my entire "uses" section for reference:

<uses-permission                        android:name="android.permission.CAMERA" />
<uses-feature android:required="false"  android:name="android.hardware.camera" />
<uses-feature android:required="false"  android:name="android.hardware.camera.autofocus" />
<uses-feature android:required="false"  android:name="android.hardware.camera.front"/>

<uses-permission                        android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-feature android:required="false"  android:name="android.hardware.WRITE_EXTERNAL_STORAGE" />

<uses-permission                        android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-feature android:required="false"  android:name="android.hardware.READ_EXTERNAL_STORAGE" />

<uses-permission                        android:name="android.permission.READ_PHONE_STATE"/>
<uses-feature android:required="false"  android:name="android.hardware.READ_PHONE_STATE"/>

<uses-permission                        android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-feature android:required="false"  android:name="android.hardware.ACCESS_NETWORK_STATE"/>

<uses-permission                        android:name="android.permission.INTERNET" />
<uses-feature android:required="false"  android:name="android.hardware.INTERNET" />

<uses-permission                        android:name="android.permission.FLASHLIGHT" />
<uses-feature android:required="false"  android:name="android.hardware.FLASHLIGHT" />

<uses-permission                        android:name="android.permission.VIBRATE" />
<uses-feature android:required="false"  android:name="android.hardware.vibrate" />

<uses-permission                        android:name="android.permission.CALL_PHONE" />
<uses-feature android:required="false"  android:name="android.hardware.CALL_PHONE"/>

<uses-permission                        android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission                        android:name="asn.apps.asncrm.permission.C2D_MESSAGE" />
<uses-permission                        android:name="com.google.android.c2dm.permission.SEND" />
<uses-permission                        android:name="android.permission.WAKE_LOCK" />

<uses-feature android:required="false"  android:name="android.hardware.telephony"/>
JeffT
  • 181
  • 2
  • 9
  • Why do you want to ask camera permission without requiring camera hardware? – Niko Adrianus Yuwono Nov 04 '15 at 00:54
  • There's a spot in the app where they can open up the camera to take a picture. But that's optional and not required for the rest of the app to run properly. – JeffT Nov 04 '15 at 15:39
  • Won't fix your issue, but you should use `android.hardware.camera2` since `android.hardware.camera` as been deprecated in API 21. http://developer.android.com/reference/android/hardware/Camera.html – 3lil636wm Nov 06 '15 at 22:34
  • what is your minimum sdk? – Ilario Nov 06 '15 at 22:41
  • minSdkVersion 15 targetSdkVersion 22 – JeffT Nov 06 '15 at 22:52
  • The vast majority of your `` elements are bogus. You cannot just invent new feature names like `android.hardware.INTERNET`. So, start by removing the invalid `` elements, restricting yourself to [those that actually exist](http://developer.android.com/guide/topics/manifest/uses-feature-element.html#features-reference), and see if that helps. I just created a scrap project in Android Studio 1.4.1, added the first four lines from your manifest snippet to the project's manifest, and `aapt dump badging` shows that the features are not required. – CommonsWare Nov 09 '15 at 16:05

2 Answers2

8

Try adding this additional tag to your Android manifest:

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

This reason for this is that, according to the docs, the android.permission.CAMERA permission implies the following 2 features are required: android.hardware.camera and android.hardware.camera.autofocus.

[EDITED]

Also, if you have any <uses-library> tags in you manifest, one of the libraries may require a camera feature.

cybersam
  • 63,203
  • 6
  • 53
  • 76
  • Thanks for the reply. I do already have that in there and edited my answer to provide the rest of my "Uses" section of the androidmanifest.xml – JeffT Nov 06 '15 at 23:22
  • 1
    Do you have any `` tags in you manifest? If so, one of the libraries may require a camera feature. – cybersam Nov 07 '15 at 00:02
  • I think you're on to something here - i'm referencing the PDF417.mobi's classes. If they are somehow making the camera be required, is there any way to override that? – JeffT Nov 09 '15 at 16:24
  • Not that I know of; and I would be surprised if there was a way to override a library's requirements, since that would make the library unreliable and possibly crash your app. – cybersam Nov 09 '15 at 17:06
  • The library i referenced was a .aar file. I was able to unzip the .aar file and edit their AndroidManifest.xml file and add android:required="false" to the camera line. Then re-zip the files and re-build the project and it fixed my issue – JeffT Nov 12 '15 at 19:21
0

In my application where I want to override the camera permission i.e make the app available for devices without camera, I declare manifest permissions as shown below. I have verified that app is available on play store on devices without camera.

Not sure if this would help you overcome your issue( since you mentioned usage of third party library) but please give it a try and let me know.

<uses-permission android:name="android.permission.CAMERA" />

<uses-feature
    android:name="android.permission.CAMERA"
    android:required="false" /> // this is the one I have extra, please add and test

<uses-feature
    android:name="android.hardware.camera"
    android:required="false" />
<uses-feature
    android:name="android.hardware.camera.autofocus"
    android:required="false" />
Natarajan Raman
  • 606
  • 1
  • 4
  • 14