17

I'm following this guide to use com.android.future.usb library on API 10.

I've done the following:

  • Installed Google APIs 10 from SDK Manager: GoogleAPI10
  • Chose Google APIs 10 as my Project Build Target: ProjectTarget
  • Added these to manifest:

<uses-feature android:name="android.hardware.usb.accessory" /> (direct child of <manifest>)

<uses-library android:name="com.android.future.usb.accessory" /> (child of <application>)

<meta-data android:name="android.hardware.usb.action.USB_ACCESSORY_ATTACHED" android:resource="@xml/accessory_filter" /> (child of first activity)

  • Created res/xml/accessory_filter.xml as mentioned here.

Doing this allowed me to use com.android.future.usb and its sub classes. But the problem is the application won't start after the changes in manifest.

This is a rooted device, and this application is configured by the OS to start automatically on device startup.

Should I do any other configurations to make this work? Maybe something should be done in the firmware?

edit:

Here's logcat with everything relating to usb:

USB mass storage support is not enabled in the kernerl
usb_configuration switch is not enabled in the kernerl
Volume usb state changing -1 (Initializing) -> 0 (No-Media)
Ignoring unknown switch 'usb_connected'
Package com.example.gui requires unavailable shared library com.android.future.usb.accessory: failing!
Skipping unknown volume '/mnt/usb'
USB Service
This kernel does not have USB configuration switch support
Alaa M.
  • 4,961
  • 10
  • 54
  • 95

1 Answers1

-1

It's not clear what you mean by the application won't start.

If you are expecting the application to start automatically on device startup. This has the instructions for doing that: How to start an Application on startup?

If the problem is the application will not compile, more information on the error encountered will be needed.

You mention that you made changes to the manifest per the link you provided. That example also includes an intent-filter tag to the activity element in the manifest, which you did not mention. So the activity element in the manifest would have two intent-filters:

        <activity
        android:name=".MainActivity"
        android:label="@string/app_name"
        android:theme="@style/AppTheme.NoActionBar" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
        <intent-filter>
            <action android:name="android.hardware.usb.action.USB_ACCESSORY_ATTACHED" />
        </intent-filter>

        <meta-data android:name="android.hardware.usb.action.USB_ACCESSORY_ATTACHED"
                   android:resource="@xml/accessory_filter" />

    </activity>

So, your application not starting might be because you removed the MAIN / LAUNCHER intent filter from your activity manifest?

Community
  • 1
  • 1
Leo Landau
  • 1,785
  • 17
  • 25
  • As I said "the application won't start **after** the changes in manifest." Which means, the application used to start before the changes. So linking a "How to start an application on startup" is not relevant. And the intent is not necessary for **starting** the application. The intent is just for waiting for the action ('usb_attached'). And no I did not remove the main intent... – Alaa M. Nov 05 '15 at 06:59