【发布时间】:2011-05-26 17:43:40
【问题描述】:
我尝试为我的应用程序实现蓝牙通信,但我仍然卡在发现设备部分。
因此,我尝试实现 google 提供的蓝牙聊天示例,但出现了一些错误。
事实上,Ecpise 告诉我必须导入android.R,但我知道这是来自 Eclipse 的错误。看来主要问题是无法识别xml布局文件。
我的控制台出现了一些错误:
[2011-05-26 15:30:46 - androidBthChat] E:\DATA\Simon\simon\Travail\Workspace_Eclipse\androidBthChat\res\layout\device_list.xml:8: error: Error: No resource found that matches the given name (at 'text' with value '@string/title_paired_devices').
[2011-05-26 15:30:46 - androidBthChat] E:\DATA\Simon\simon\Travail\Workspace_Eclipse\androidBthChat\res\layout\device_list.xml:23: error: Error: No resource found that matches the given name (at 'text' with value '@string/title_other_devices').
[2011-05-26 15:30:46 - androidBthChat] E:\DATA\Simon\simon\Travail\Workspace_Eclipse\androidBthChat\res\layout\device_list.xml:38: error: Error: No resource found that matches the given name (at 'text' with value '@string/button_scan').
[2011-05-26 15:30:46 - androidBthChat] E:\DATA\Simon\simon\Travail\Workspace_Eclipse\androidBthChat\res\layout\main.xml:26: error: Error: No resource found that matches the given name (at 'text' with value '@string/send').
[2011-05-26 15:30:46 - androidBthChat] E:\DATA\Simon\simon\Travail\Workspace_Eclipse\androidBthChat\res\menu\option_menu.xml:4: error: Error: No resource found that matches the given name (at 'title' with value '@string/secure_connect').
[2011-05-26 15:30:46 - androidBthChat] E:\DATA\Simon\simon\Travail\Workspace_Eclipse\androidBthChat\res\menu\option_menu.xml:8: error: Error: No resource found that matches the given name (at 'title' with value '@string/insecure_connect').
[2011-05-26 15:30:46 - androidBthChat] E:\DATA\Simon\simon\Travail\Workspace_Eclipse\androidBthChat\res\menu\option_menu.xml:12: error: Error: No resource found that matches the given name (at 'title' with value '@string/discoverable').
然后,直接使用 android 文件中的 API,当 Eclipse 让我导入 com.example.android.BluetoothChat.R 时,我感到很惊讶。我做到了,以前的所有错误都消失了。我编译后,应用程序直接在模拟器和我的 Desire 上崩溃。
那么,你对我的问题有什么线索吗?是安卓版本的问题吗?缺少包裹?日食错误?
由于您的担心,我没有接触蓝牙聊天示例的代码,我尝试使用 2.1 和 3.0 android 版本进行编译。
所以,我要提前感谢您的帮助,无论它是什么:学习蓝牙 API 的线索或最简单的教程。
问候。
感谢 Lister,但我已经在 Android Manifest 中编写了两个蓝牙权限。 这不是我的问题的原因。
我刚读到这个:android.R cannot be resolved
我检查一下:
- 清单中的包路径
- java 文件中的包路径
我在相关文件中写了com.androidBthChat。
然后,我尝试编译,在模拟器中运行应用程序,但我遇到了同样的崩溃错误,路径包错误:
The application Bluetooth Chat(process com.example.anndroid.BluetoothChat) has stopped unexpectedly.
Please try again.
所以,我们可以看到应用程序正在搜索错误的路径包。我是否必须使用 android 示例重新创建相同的路径包?
你有什么想法吗?你想要关于我的代码的其他精度吗?
感谢您的回答。
大家好,
我几乎解决了我的问题。现在我能:
- 编译Bth Chat android项目没有错误,
- 无崩溃启动,
- 并发现设备(例如我的诺基亚手机)。
但我无法将诺基亚连接到 htc 的愿望。我假设我必须使用具有相同应用程序的其他 android 手机。我会尽快做的。
为了得到这个结果,我首先重新创建了整个项目,并得到了作者的建议:Oscilo_Bth。参照。 UUID_issue。
我将 UUID 更改为 00001101-0000-1000-8000-00805F9B34FB。
我很快就会带着新的结果回来。
【问题讨论】:
标签: android eclipse bluetooth uuid