android蓝牙聊天示例的错误:布局未知且API的修改没有崩溃

问题描述

| 我尝试为我的应用程序实现蓝牙通信,但是我仍然停留在发现设备部分。 因此,我尝试实现由Google提供的蓝牙聊天示例,但出现一些错误。 确实,Ecplise告诉我,我必须导入@H_502[email protected],但是我知道这是Eclipse的错误。似乎主要问题是无法识别xml布局文件。 我从控制台收到一些错误信息: @H_502_1@[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提供我导入@H_502[email protected]etoothChat.R时,我感到惊讶。我做到了,以前所有的错误都消失了。我编译后,应用程序直接在eumator和Desire上崩溃。 那么,您对我的问题有什么线索吗?是android版本问题吗?缺少包裹? Eclipse错误? 为了您的关心,我没有触及Bluetooth Chat示例的代码,而是尝试使用2.1和3.0 android版本进行编译。 因此,我想在此先感谢您的帮助,无论它是什么:学习蓝牙API的线索或最简单的教程。 问候。 感谢Lister,但我已经在Android Manifest中编写了两个蓝牙权限。 这不是我的问题的原因。 我刚刚读到这个:android.R无法解析 我检查: 清单中的包路径 Java文件中的包路径 我在有关文件中写了“ 3”。 然后,我尝试进行编译,以在模拟器中运行该应用程序,但我得到了同样的崩溃错误,但路径包错误@H_502_1@The application Bluetooth Chat(process com.example.anndroid.BluetoothChat) has stopped unexpectedly. Please try again. 因此,我们可以看到应用程序正在搜索错误的路径包。我是否必须使用android示例重新创建相同的路径包? 你有想法吗?您是否希望其他人对我的代码有精度? 谢谢您的回答。 大家好, 我几乎解决了我的问题。现在我能: -正确编译Bth Chat android项目, -发射时不会崩溃, -并发现设备(例如我的诺基亚手机)。 但是我无法将诺基亚与htc欲望联系起来。我假设我必须使用具有相同应用程序的其他Android手机。我会尽快做的。 为了获得此结果,我首先重新创建了整个项目,并从其作者Oscilo_Bth得到了建议。 cf. UUID_issue。 我将UUID更改为@H_502_1@00001101-0000-1000-8000-00805F9B34FB。 我很快就会得到新结果。     

解决方法

如果尚未完成,请确保已在manifest.xml中设置了正确的权限 我提到它是因为这是我多次重复的错误,直到我终于学会为止,所以其他人也可能会遇到。我将花费大量时间尝试找出问题所在,然后记住权限并将其放入,然后就可以了。     ,我遇到了一些类似的问题。 您是否将条目放入字符串文件中? 这是蓝牙示例附带的字符串文件: http://developer.android.com/resources/samples/BluetoothChat/res/values/strings.html     ,注意:我可以编译文件并将其上传到我的阿尔卡特908,但是由于某种原因该程序崩溃。 我所做的是获取R.java文件,该文件会导致我以前创建的自己可以正常工作的项目中的大多数错误(如果您是初学者,则不需要开发的应用程序,只需启动一个新的android项目并R.java将自动生成)。要在“项目”视图中找到此文件,请一直扩展到
ProjectName/gen/com.PACKAGENAME/R.java
在BluetoothChatService.java文件中: 搜索
listenUsingInsecureRfcommWithServiceRecord
并删除 与这部分相关的代码。 保持ѭ8不变。我也 删除了ѭ9,因为我不知道如何使用它: 删除了导入和您要删除的一些
setStatus
代码段 可以通过搜索文件找到。我认为应该是这样。