Errors for the android Bluetooth Chat example: layout unkown and API free of modifications crashed
I try to implement bluetooth communication for my application but I'm still stuck on the discover devices part.
So, I try to implement the Bluetooth Chat example provided by google but I get some errors.
Indeed, Ecplise tells me that I have to import android.R
but I know that it is an error from Eclipse. It seems that the major issue is that xml layout files are not recognized.
I got some erros from my console:
[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').
Then, using directly the API in the android files, I was surprised when Eclipse offered me to import com.example.android.BluetoothChat.R
. I did it and all the previous errors disappeared. I compiled and the application crash directly on the emuator and on my Desire.
So, do you have any clues for my problem? Is it android version issue? Missing package? Eclipse error?
For your concern, I didn't touch the code of Bluetooth Chat example and I tried to compile with 2.1 and 3.0 android version.
So, I want to thank you, in advance, for your help, whatever it is: clues or easiest tutorial to learn Bluetooth API.
Regards.
Thanks Lister but I have already written the two bluetooth permissions in the Android Manifest. This is not the cause of my issue.
I just read this: android.R cannot be resolved
And I check:
- Package path in the manifest
- Package path开发者_运维百科 in the java files
I wrote com.androidBthChat
in the files concerned.
Then, I tried to compile, to run the application in the emulator and I just got the same crashed error with wrong path package:
The application Bluetooth Chat(process com.example.anndroid.BluetoothChat) has stopped unexpectedly.
Please try again.
So, we can see that the application is searching the wrong path package. Do i have to recreate the samed path package using android example?
Do you have an idea? Do you want others precisions regarding my code?
Thank you for your answers.Hi All,
I have nearly resolved my problem. Now, I can:
- compile the Bth Chat android project without errors, - launch without crash, - and discover devices (my nokia cellphone for example).But I can not connect the nokia to the htc desire. I assume that I have to use an other android phone with the same application. I will do it soon.
To get this result, I have first recreated the whole project and got advices from the author of this: Oscilo_Bth. Cf. UUID_issue.
I change the UUID to 00001101-0000-1000-8000-00805F9B34FB
.
I will get back soon with new results.
If you haven't already done it, make sure that you have put the right permissions in the manifest.xml
I mention it because it is a mistake I repeated many times until I finally learnt so maybe it happens to others as well. I would spend a lot of time trying to figure out what was wrong then I remember about the permissions and put them in and then it is OK.
I ran into some similar issues.
Did you put entries in your strings file?
Here is the strings file that goes with the bluetooth example:
http://developer.android.com/resources/samples/BluetoothChat/res/values/strings.html
Note: I can compile the file and upload it to my Alcatel 908 but the program crashes for some reason.
What I did was get the R.java file that causes most of the errors from a project that I previously created myself and worked properly (you don't need a developed app if you are a beginner, just start a new android project and R.java will be automatically generated). To find this file in the Project view expand all the way to ProjectName/gen/com.PACKAGENAME/R.java
In BluetoothChatService.java file:
- Search for
listenUsingInsecureRfcommWithServiceRecord
and delete the code related to this piece. - Leave the
listenUsingRfcommWithServiceRecord
untouched. I also removed theActionBar
because I don't know how to use it: - Removed the import and a few
setStatus
pieces of code which you could find by searching the file. I think this should be it.
精彩评论