androidextjssencha-touch-2google-playsencha-cmd

Sencha Touch native optional features vs required permissions (camera on Nexus 7)


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.


Solution

  • 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>