如何让 ADK DemoKit 示例在 Google I/O Galaxy Tab 10.1 上运行?
我正在尝试让 DemoKit 示例 正常工作在 ADK 板上。似乎即使有了 3.1 更新,Galaxy Tab 也没有提供所需的一切(或者至少不像宣传的那样工作)。即使仔细研究了文档,三星 Kies 应用程序似乎也可能会造成阻碍。
如果我按照指示使用 API 级别 10 库,它就不会运行(单步执行调试器,我看到此异常:java.lang.NoClassDefFoundError: com.android.future.usb.UsbManager
)。如果我使用 API 级别 12 库,也会发生同样的情况。
将目标设置为 3.1 平台(只需在项目属性中更改它),它将无法编译(由于使用 com.android.future.usb
库)。我找到了一些您必须执行的一些更改的文档在 3.1 上使用 USB 包,这些是我对 DemoKitActivity.java 所做的更改,
37,38c37
< import com.android.future.usb.UsbAccessory;
< import com.android.future.usb.UsbManager;
---
> import android.hardware.usb.*;
128c127
< UsbAccessory accessory = UsbManager.getAccessory(intent);
---
> UsbAccessory accessory = (UsbAccessory) intent.getParcelableExtra(UsbManager.EXTRA_ACCESSORY);
139c138
< UsbAccessory accessory = UsbManager.getAccessory(intent);
---
> UsbAccessory accessory = (UsbAccessory) intent.getParcelableExtra(UsbManager.EXTRA_ACCESSORY);
152c151
< mUsbManager = UsbManager.getInstance(this);
---
> mUsbManager = (UsbManager) getSystemService(Context.USB_SERVICE);
即使在进行这些更改之后,我仍然遇到了问题。它现在已安装,并且 DemoKit 应用程序的初始屏幕出现“请连接 DemoKit 板”,但每当我连接 ADK 板并关闭 USB 调试(打开它时,它什么也不做),我只是得到Samsung Kies 应用程序显示“按 home 键退出 Samsung Kies”,但其他按钮没有响应。点击主页并返回 DemoKit 应用程序只会再次显示连接屏幕,并且它从未真正连接到开发板。
如何才能使其发挥作用? ADK 是否可以与 Galaxy Tab 10.1(Google I/O 版)配合使用?如果可以,我的方向是否正确?
更新
无论平板电脑上的调试模式是否打开或关闭,Arduino 串行监视器都会显示以下内容(需要将波特率设置为 115200 才能读取输出):
设备寻址...请求设备描述符。
找到可能的设备。切换到串行模式
数据包错误:5无法读取设备协议版本
插入平板电脑时会不断重复。
更新2
我意识到我没有更新AndroidManifest.xml
文件...更改:
<uses-sdk android:minSdkVersion="10" android:targetSdkVersion="11" />
到
<uses-sdk android:minSdkVersion="12" android:targetSdkVersion="12" />
和
<uses-library android:name="com.android.future.usb.accessory"/>
到
<uses-feature android:name="android.hardware.usb.accessory"/>
一旦我纠正了它,它似乎没有改变任何东西。
更新 3
我已向三星支持发送电子邮件,正在等待回复。
I'm trying to get the DemoKit example working on an ADK board. It seems like even with the 3.1 update the Galaxy Tab doesn't have everything it needs (or at least doesn't work as advertised). And even with digging though the documentation it seems like the Samsung Kies app is possibly getting in the way.
It won't run if I use the API Level 10 Libraries as instructed (stepping through the debugger I see this exception: java.lang.NoClassDefFoundError: com.android.future.usb.UsbManager
). The same thing happens if I use the API Level 12 Libraries.
Setting the target to be the 3.1 platform (simply changing it in the project properties) it won't compile (due to use of the com.android.future.usb
library). I found some documentation of some changes that you have to do to use the USB package on 3.1 and from that, these are the changes I made to DemoKitActivity.java
37,38c37
< import com.android.future.usb.UsbAccessory;
< import com.android.future.usb.UsbManager;
---
> import android.hardware.usb.*;
128c127
< UsbAccessory accessory = UsbManager.getAccessory(intent);
---
> UsbAccessory accessory = (UsbAccessory) intent.getParcelableExtra(UsbManager.EXTRA_ACCESSORY);
139c138
< UsbAccessory accessory = UsbManager.getAccessory(intent);
---
> UsbAccessory accessory = (UsbAccessory) intent.getParcelableExtra(UsbManager.EXTRA_ACCESSORY);
152c151
< mUsbManager = UsbManager.getInstance(this);
---
> mUsbManager = (UsbManager) getSystemService(Context.USB_SERVICE);
Even after making those changes I've been running into issues though. It installs now and the initial screen for the DemoKit app comes up with the "Please connect a DemoKit board", but whenever I connect the ADK board and turn off USB debugging (with it on it, it does nothing), I just get the Samsung Kies app which says "Press the home key to quit Samsung Kies" and no other buttons respond. Hitting home and going back into the DemoKit app just shows the connect screen again and it never really connects to the board.
How can this be made to work? Does the ADK work with the Galaxy Tab 10.1 (Google I/O edition) and if so, am I on the right track?
UPDATE
Here's what the Arduino serial monitor says regardless if debug mode is on or off on the tablet (need to set the baud rate to 115200 to read the output):
Device addressed... Requesting device descriptor.
found possible device. swithcing to serial mode
Data packet error: 5could not read device protocol version
It repeats constantly while it's plugged in to the tablet.
UPDATE 2
I realized I didn't update the AndroidManifest.xml
file... Changing:
<uses-sdk android:minSdkVersion="10" android:targetSdkVersion="11" />
to
<uses-sdk android:minSdkVersion="12" android:targetSdkVersion="12" />
and
<uses-library android:name="com.android.future.usb.accessory"/>
to
<uses-feature android:name="android.hardware.usb.accessory"/>
It didn't seem to change anything once I got that corrected.
UPDATE 3
I have emailed Samsung support and am awaiting a reply.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
抱歉,配件模式目前不适用于 Samsung Galaxy Tab 10.1。三星已意识到该问题并正在努力解决。当设备支持配件模式时,您应该能够使用 com.android.future.usb.* API,这将使您更轻松地编写适用于 Android 3.1 和 2.3.4 的应用程序。
My apologies, accessory mode currently doesn't work with the Samsung Galaxy Tab 10.1. Samsung is aware of the issue and is working on resolving it. When the device does support accessory mode you should be able to use the com.android.future.usb.* APIs which will make it easier for you to write an app that works both with Android 3.1 and 2.3.4.
我刚刚获得了新的 TouchWiz 更新,现在 Arduino 将其读回到串行端口:
这看起来好多了。 Galaxy Tab 要求运行 DemoKit,我点击“确定”,然后它强制退出。这比以前好多了。
如果我让它完全正常工作,我会更新。
I just got the new TouchWiz update and now the Arduino reads this back to the serial port:
This is looking much better. The Galaxy Tab asks to run DemoKit, I hit OK, and it force quits. This better than it was previously.
I will update if I get it working fully.
您确定您使用的是正确的构建目标吗?您应该使用“Google API”目标,而不是常规的“Android 2.3.3”(级别 10)或“Android 3.1”(级别 12)。如果您运行“Android SDK 和 AVD Manager”,您可以在“可用包”>“可用包”下找到它们。第三方附加组件>谷歌公司> “Google Inc. 的 Google API,Android API 10”(或 12)。
Are you sure you are using the right build target? Instead of regular "Android 2.3.3" (level 10) or "Android 3.1" (level 12), you should use "Google APIs" targets. If you run "Android SDK and AVD Manager", you can find them under Available Packages > Third party add-ons > Google Inc > "Google APIs by Google Inc., Android API 10" (or 12).
我的 Android 3.1 上的 Galaxy Tab 10.1 也没有配件 API 作为向后移植。因此,我也遇到了以下异常:
使其在 Android 3.1 的 Tab 10.1 上运行的一种方法是使用常规附件 API。不是向后移植的版本。您可以将 DemoKit 项目的目标 SDK 设置为常规 API 级别 12 (Android 3.1)。
此外,您必须将 DemoKitActivity 中的代码段落更改为获取 UsbManager 和 UsbAccesory:
导入更改为:
Android 清单仍然可以包含以下条目,但不再需要:
My Galaxy Tab 10.1 on Android 3.1 didn't have the accessories API as a backport as well. So I got the following exception as well:
One way to bringing it to work on the Tab 10.1 with Android 3.1 is to use the regular accessory API. Not the backported version. You can set your DemoKit projects target SDK to the regular API level 12 (Android 3.1).
In addition you have to change the code passages in the DemoKitActivity to get the UsbManager and the UsbAccesory to:
imports change to:
The Android manifest can still contain the following entry but it is not required anymore: