使用`com.android.future.usb.accessory`库时,应用程序无法启动

Ala*_* M. 17 usb android

我正在按照本指南com.android.future.usb在API 10上使用库.

我做了以下事情:

  • 从SDK Manager安装了Google API 10: GoogleAPI10
  • 选择Google API 10作为我的项目构建目标: ProjectTarget
  • 将这些添加到manifest:

<uses-feature android:name="android.hardware.usb.accessory" /> (直接孩子<manifest>)

<uses-library android:name="com.android.future.usb.accessory" /> (孩子的<application>)

<meta-data android:name="android.hardware.usb.action.USB_ACCESSORY_ATTACHED" android:resource="@xml/accessory_filter" /> (第一个孩子activity)

  • 创建res/xml/accessory_filter.xml提到这里.

这样做允许我使用com.android.future.usb它的子类.但问题是应用程序在更改后无法启动manifest.

这是一个root设备,该应用程序由OS配置为在设备启动时自动启动.

我应该做任何其他配置才能使这项工作?也许应该在固件中做些什么?

编辑:

这是logcat与所有相关的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
Run Code Online (Sandbox Code Playgroud)

Leo*_*dau -1

目前尚不清楚你的意思是什么the application won't start

如果您期望应用程序启动automatically on device startup。这有执行此操作的说明:如何在启动时启动应用程序?

如果问题是应用程序无法编译,则需要有关遇到的错误的更多信息。

您提到您根据您提供的链接对清单进行了更改。该示例还包括intent-filter清单中活动元素的标签,您没有提及。因此清单中的活动元素将有两个意图过滤器:

        <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>
Run Code Online (Sandbox Code Playgroud)

那么,您的应用程序未启动可能是因为您从活动清单中删除了 MAIN / LAUNCHER 意图过滤器?