I'm developing an app with ionic and cordova. when i'm done building and i do ionic cordova prepare android and i go to android studio to deploy on the phone i get camera duplications in Androidmanifest.xml and i have to manually clean it up to allow a successful deployment.
Android.manifest after ionic cordova prepare android
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" android:required="false" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.FLASHLIGHT" />
<uses-feature android:name="android.hardware.camera" android:required="false" />
<uses-feature android:name="android.hardware.camera" android:required="true" />
What i want to achieve is to configure the config.xml so that it doesn't happen that i'd always have to clean the camera duplicate in Androidmanifest.xml
after manually cleaning which makes it work
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" android:required="false" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.FLASHLIGHT" />
I tried this in config.xml but it didn't work
<edit-config file="app/src/main/AndroidManifest.xml" mode="overwrite" target="/manifest/uses-feature[#android:name='android.hardware.camera']">
<uses-feature android:name="android.hardware.camera" />
</edit-config>
Try using cordova-custom-config.
ionic cordova plugin add cordova-custom-config
config.xml:
<platform name="android">
....
<custom-preference delete="true" name="android-manifest/uses-feature[#android:name='android.hardware.camera']" />
</platform>
Then remove and add your android platform:
ionic cordova platform rm android
ionic cordova platform add android#your_version
I think the best way to solve this is to find out why those contradicting uses-feature's are added in the first place and remove them there.
I'd also try the solution SidiBecker suggested, because it is quite elegant.
However, if that doesn't work, you can remove code from your android manifest programatically with an after_prepare hook, the same way as I suggested in this answer: use config.xml to control how plugins are installed
Related
Showing error while running in esc_pos_bluetooth in flutter I added permission in manifest page like this.
<uses-permission android: name="android.permission.BLUETOOTH" android:maxSdkVersion="31" tools:targetApi="donut" /> <uses-permission android: name="android.permission.BLUETOOTH_ADMIN" android:maxSdkVersion="31" tools:targetApi="donut" /> <uses-permission android: name="android.permission.BLUETOOTH_SCAN" tools:targetApi="31" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" android:maxSdkVersion="31" tools:targetApi="donut" /> <uses-permission android:name="android.permission.BLUETOOTH_ADVERTISE" /> <uses-permission android:name="android.permission.BLUETOOTH_CONNECT" /> <uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" android:maxSdkVersion="31" tools:targetApi="donut" /> <uses-permission android: name="android.permission.ACCESS_COARSE_LOCATION" />.
And still having the error.
Error starting scan. E/flutter (16326): [ERROR: flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: Platform Exception(startscan, Need android.permission.BLUETOOTH_SCAN permission for android.content.AttributionSource#8a7ab34e: GattService register Scanner, null, null).
this problem is only showing in android 10 or above devices only. under android 10 version phones support this smoothly and showing near devices also.
Using 0.4.1 with the following manifest on a real device works for me:
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
<uses-permission android:name="android.permission.BLUETOOTH_ADVERTISE" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
<uses-feature android:name="android.hardware.bluetooth" android:required="true"/>
<uses-feature android:name="android.hardware.bluetooth_le" android:required="true"/>
What you are missing is the uses-feature flag. Check it out here
You can also read about hickups für Bluetooth < 12.0 on Android here
Our app fails to install after migrating to the targetSdkVersion 31. On trying to find the issue we found that a library was using FLASHLIGHT permission and we were getting this error while installing:
Installation failed due to: 'Failed to commit install session
130765275 with command cmd package install-commit 130765275. Error:
-127: Package com.xxxx.yyyy.zzzz attempting to declare permission android.permission.FLASHLIGHT in non-existing group
android.permission-group.HARDWARE_CONTROLS'
Permissions used in the manifest file of library:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />
<permission
android:name="android.permission.FLASHLIGHT"
android:permissionGroup="android.permission-group.HARDWARE_CONTROLS"
android:protectionLevel="normal" />
Is there any workaround to this issue?
android.permission-group.HARDWARE_CONTROLS is deprecated in targetSdkVersion 31 . The work around is to remove the permission used by library in your manifest by
<permission
android:name="permissionOne"
tools:node="remove"
tools:selector="com.example.lib1">
tools:node="remove"
will remove the permission from the App if its used in any of your libraries
I am using react-native-webview version 4.0.2 . So I have a webview that contains an add button that allows us to take picture with the camera but when clicking at that button nothing is shown and no camera permission shown. This is on android side but working very well on ios (i can see permission and access to camera ).
In my AndroidManifest.xml I do have :
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" android:required="false"/>
<uses-feature android:name="android.hardware.camera.autofocus" android:required="false"/>
So please do you have any suggestion ?
Try using:
<uses-sdk
android:minSdkVersion="23"
android:targetSdkVersion="__APILEVEL__" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"
android:maxSdkVersion="18" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="18" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.RECORD_AUDIO"
android:maxSdkVersion="18" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"
android:maxSdkVersion="18" />
1st step:
use this in AndroidManifest.xml file
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
2nd step:
Grant multiple permission in App.js file
const granted = await PermissionsAndroid.requestMultiple([
PermissionsAndroid.PERMISSIONS.CAMERA,
PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION,
PermissionsAndroid.PERMISSIONS.ACCESS_COARSE_LOCATION,
]);
3rd step:
use these properties inside webview
geolocationEnabled={true}
mediaPlaybackRequiresUserAction={false}
javaScriptEnabled={true}
you need to add this too inside webview mediaPlaybackRequiresUserAction={false}
If you use Expo, in my case, temporarily, I solve it by doing this. In the website's code, not the react-native code, change
navigator.mediaDevices.getUserMedia({video : true, audio:true})
to
navigator.mediaDevices.getUserMedia({video : true})
In the long term, if you use Expo, you should switch to React Native cli
I'm extending an ios app to the android platform - I'm unfamiliar with the android tools but following the tuts.
I have added the platform but when I run the 'cordova build android' I get errors on the AndroidManifest.xml
When I trace this it seems that lines are being added in the uses-permission section (see the last 3) that have no android namespace
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="22" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.READ_CALENDAR" />
<uses-permission android:name="android.permission.WRITE_CALENDAR" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_CONTACTS" />
<uses-permission name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission name="android.permission.READ_PHONE_STATE" />
if I add the namespace and rebuild, the error becomes one of duplication. If I delete the offending lines, then the rebuild just re-writes them.
The ios version of my app works perfecto, so I'm assuming its something to do with how the plugins write to this file on android build.
Before I start to debug by unpicking the plugins, has anyone else been here before and resolved it, and are hungry for upvotes?
I am afraid you need to setup the issue manually as that is not resolved yet, its still alive.
You have to open your plugins/android.json and remove the duplicate keys in there. In your case search for WRITE_EXTERNAL_STORAGE, MODIFY_AUDIO_SETTINGS, READ_PHONE_STATE in android.json and remove the duplicates.
Then open up platforms/android/AndroidManifest.xml and remove the duplicate <uses-permission... /> tags. And then rebuild and try again.
The play store is showing that my app is not compatible with the Nexus 7 (older model with only front-facing camera, ME370T). My app does require a camera but can use the front-facing camera. I tried to take this into account in my Manifest by specifying that any camera could be used (not just the back facing camera):
<uses-feature android:name="android.hardware.camera.any" />
Otherwise, I have no idea why it's not able to run on the Nexus 7. Here are my permissions:
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-feature android:name="android.hardware.camera.any" />
<uses-feature android:name="android.hardware.camera.autofocus" android:required="false" />
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="19" />
Any ideas why I can't install the app?
It seems like the app store may ignore the "any" specification for uses-feature. I changed my camera requirement to
<uses-feature android:name="android.hardware.camera" android:required="false" />
and it seems like it's supported now.