简体   繁体   中英

Android app force closing when opening amarino connection

I am new to android development, and have run into a problem I seem unable to solve. My android app should be able to communicate with my arduino device, sending info to and retrieving info from my device. I have set up my connection between the two with a bluetooth device and I am using amarino to facilitate the communication.

Now I can connect with amarino and send data and receive data, now I want to do this from my app. The problem comes when I enter this line:

private static final String DEVICE_ADDRESS = "07:12:04:16:68:18"; 
Amarino.connect(this, DEVICE_ADDRESS);

The number is the MAC address of my bluetooth adapter connected to my arduino device. As soon as I run my app on my phone it just force closes due to unexpected error. Now as I said, I am a bit of a noob when it comes to android, so I installed logCat to try get some log info out of it. All I got from it was this somewhat unhelpful error message:

com.example.projectgreetv3/.StartingPlace 10-24 15:22:55.140 E/AndroidRuntime(4906): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.projectgreetv3/com.example.projectgreetv3.StartingPlace}: java.lang.ClassNotFoundException: com.example.projectgreetv3.StartingPlace in loader dalvik.system.PathClassLoader[/data/app/com.example.projectgreetv3-1.apk] 10-24 15:22:55.140 E/AndroidRuntime(4906): Caused by: java.lang.ClassNotFoundException: com.example.projectgreetv3.StartingPlace in loader dalvik.system.PathClassLoader[/data/app/com.example.projectgreetv3-1.apk] 10-24 15:22:55.148 W/ActivityManager(539): Force finishing activity com.example.projectgreetv3/.StartingPlace 10-24 15:21:51.726 I/UinboxLogger(4585): [UinboxReceiver] onReceive() >> intent.getData() : com.example.projectgreetv3 10-24 15:21:52.382 I/UninstallAppProgress(4575): Finished uninstalling pkg: com.example.projectgreetv3 10-24 15:22:52.523 D/PackageManager(539): Scanning package com.examp le.projectgreetv3

I hope someone can help me with this, as I am on wits end.

For more info on: - Arduino: - http://www.arduino.cc/ - Amarino: http://www.amarino-toolkit.net/

If you look a bit further down on your stacktrace (in the logcat) you will probably see that the cause of this crash is an NetworkOnMainThreadException. (If you are running Android 3.0 or higher)

Please make sure that you do all your network communication on a separate thread (Thread/ASyncTask).

http://developer.android.com/reference/android/os/NetworkOnMainThreadException.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM