I have an ios/android app built using cordova (cli-8.0.0) on the Adobe Phonegap Build platform.
My app uses gps and compass. I need to make the compass a required feature, and the location a not required, but stated feature.
So I tried this in the config.xml using 'uses-feature', but in the generated Android.manifest file, only the compass one is output. Swapping the order of the two uses-feature sections in the config.xml makes the location the only one output in the manifest.
What am I doing wrong??
Chris
<!--Android config overrides-->
<edit-config target="/manifest/uses-feature" file="AndroidManifest.xml" mode="add" platform="android">
<uses-feature android:name="android.hardware.location" android:required="false"/>
</edit-config>
<edit-config target="/manifest/uses-feature" file="AndroidManifest.xml" mode="add" platform="android">
<uses-feature android:name="android.hardware.sensor.compass" android:required="true"/>
</edit-config>
mode="add" is right, but it also needed the target changing to "/manifest" not "/manifest/uses-feature".
Built ok, checked the manifest file and both entries are in there!
Related
I can't get the cordova-plugin-scanbot-sdk plugin to work with release builds (it works if I build in debug mode), all my plugins are with the latest version, my cordova and cordova android are also up to date.
I can use the camera and filesystem in the app without any problems, but if I try to use the scanbot the app stays on this screen but doesn't ask the user for permission to use the camera. I also tried to add the camera permission manually in config.xml using:
<edit-config file="AndroidManifest.xml" mode="merge" target="/manifest">
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
</edit-config>
but it didn't work.
Here is a screenshot of what I see when I try to open the plugin.
I am using the latest version of Cordova (6.3.1) and I want the following permission to appear in the AndroidManifest.xml :
<uses-permission android:name="android.permission.CAMERA" />
Adding this line by hand does not work because the XML is regenerated each time I run the command cordova run android
I have added the cordova-plugin-camera to my project with
cordova plugin add cordova-plugin-camera
This plugin does NOT add the CAMERA permission in the AndroidManifest.xml
I don't know if this is normal
How can I add this permission to my project ?
Edit :
Usually, Cordova plugins are in charge of adding required permissions into the manifest. The camera plugin does not add this specific permission, I wonder :
if the plugin should add this permission (bug ? I have opened an issue on their Jira tracker)
if I can add this permission by hand myself, maybe in the Cordova's config.xml
I don't think the Camera plugin ever added this permission to AndroidManifest.xml. Looking through the Github repo, WRITE_EXTERNAL_STORAGE was added in June 2013 (CB-3654), but I don't see anything for the camera itself. Not sure why that would be, but you can either add the permission to AndroidManifest.xml yourself or add a config-file directive in your project's config.xml file, for example:
<config-file target="AndroidManifest.xml" parent="/*" mode="merge">
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />
</config-file>
Are you building native or hybrid app?
For native you can refer this website:
https://developer.android.com/reference/android/hardware/Camera.html
I'd like to set androids permissions to use geolocation in config.xml.
I don't want to use cordova-plugin-geolocation which would set these settings as a side-effect because the webviews I am targeting (crosswalk) support GeoLocation out of the box. The Plugin would just be bloatware.
I don't want to write it directly in AndroidManifest.xml because I am using cordova prepare to prevent having any plattform-specific stuff inside my repository. Everybody is currently able to build the plattforms from scratch without any plattform-specific stuff from our git-repo.
What I tried
I took a look at cordova-plugin-geolocation to see how they would achieve this.
<platform name="android">
<config-file target="AndroidManifest.xml" parent="/*">
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
</config-file>
</platform>
This returns the following in my build-phase
Error: Command failed: /bin/sh -c cordova build android
/Users/sven/.../cordova/platforms/android/build/intermediates/res/armv7/debug/xml/config.xml:34: error: Error parsing XML: unbound prefix
What my next step would be
I am unsure about why the 'rob-from-cordova-plugin-geolocation'-approach does not work, but maybe it would help to just put above into a new plugin? Is it worth a try?
Your error is "unbound prefix", have you provided a definition for the "android" prefix that you're using in "android:name"?
Looking at cordova-plugin-geolocation plugin.xml you may need to add this to your XML:
xmlns:android="http://schemas.android.com/apk/res/android"
So that the android namespace is defined.
You will be able to add permissions (and many other extra configuration actions) in Cordova straight from CLI's config.xml by adding the plugin cordova-custom-config to your environment. It will add nothing in your application and consists only in a group of Cordova hooks.
So, only add the XML chuck in your config.xml (<config-file...), and also add what #SimonPrickett say in his answer.
How can I use Sencha Cmd to package a Sencha Touch 2.2 application for Google Nexus 7, with front camera support?
I'm able to run the application and take pictures fine if I install it directly on the device. But using the App Store the application is not available for Nexus 7, since Google thinks that a back-camera is required for the application.
Looking at the uses features manifest I'm supposed to set required:false on the CAMERA feature, however the manifest file is generate by Cmd based on the packager.json.
Packager.json includes "permissions": ["CAMERA"] but I can't see any option to set it optional when packaging trough Sencha Cmd.
The Camera is used in the application, but it not a required part of the applications, so I want the application to become compatible (trough Google Play Store) with none-back-camera devices like the Nexus 7.
PhoneGap may solve this problem but is currently not an option, since I use other Cmd/Native features.
Sencha CMD uses a template file C:\Users\USERNAME\bin\Sencha\Cmd\3.1.1.274\stbuild\st-res\android\AndroidManifest.xml
The file is likely used in a string format function to make the final uncompiled manifest.
I found that (at least in the latest version) I could simply add the correct tags into the template file, and remove the config from the application packager.json file.
It's important to remove the Camera config from packager.json to prevent duplication's. Since the privilege config is removed from packager.json you have to add both the privilege and the feature tag manually to the Manifest template. In this example I've also added autofocus, but currently Google ads this feature automatically if you use the camera.
Remember to change the template when compiling different applications, if the other applications do not need the camera privilege, and also when Sencha Cmd is updated.
new lines:
<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" />
complete AndroidManifext.xml after modification:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="%s" android:versionCode="%d" android:versionName="%s">
<uses-sdk android:minSdkVersion="%s" android:targetSdkVersion="15" />
<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" />
%s
<application android:icon="#drawable/icon" android:label="%s">
<activity android:name=".STActivity"
%s
android:label="%s">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
%s
%s
</activity>
</application>
</manifest>
I have an Mobile AIR project in FlashBuilder 4.6(Using AIR 3.4) and I am having a real problem publishing an APK. Here is the section from my APP XML:
<manifestAdditions><![CDATA[
<manifest android:installLocation="auto">
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.DISABLE_KEYGUARD"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
</manifest>
]]></manifestAdditions>
For some reason, when I create an APK, the INTERNET permission is being tacked on the end of the manifest permissions block. Note that the application.xml in the asset/META-INF/AIR folder still looks correct.
Any ideas where I am going wrong?
After a lot more searching, I found my own answer:
Note: When you bundle the runtime, ADT adds the INTERNET and
BROADCAST_STICKY permissions to your application. These permissions
are required by the AIR runtime.
BROADCAST_STICKY seems to no longer be required, but apparently when using captive runtime we cannot get around this.