eclipse - Fatal Exception : Main android -
with friends, we're working in project , need create android application. (i specify, i'm beginner @ programming in java).
so start i've follow tutorial (http://www.buildcircuit.com/sensorgraph-using-android-amarino-and-arduino/) explain how create connection enter arduino (microcontroller) , arduino amarino (bluetooth).
the program retrieves value of variable voltage , displays on phone.
but i've trouble, program doesn't work. when uploading on phone, show black window error message "unfortunately, sensorgraph2 has stopped" don't know can do.
this sensorgrpah.java:
package edu.mit.media.hlt.sensorgraph; import android.app.activity; import android.content.broadcastreceiver; import android.content.context; import android.content.intent; import android.content.intentfilter; import android.os.bundle; import android.widget.textview; import at.abraxas.amarino.amarino; import at.abraxas.amarino.amarinointent; public class sensorgraph extends activity { private static final string device_address = "00:15:ff:f2:0f:a8"; private graphview mgraph; private textview mvaluetv; private arduinoreceiver arduinoreceiver = new arduinoreceiver(); @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); mgraph = (graphview)findviewbyid(r.id.graph); mvaluetv = (textview) findviewbyid(r.id.value); mgraph.setmaxvalue(1024); } @override protected void onstart() { super.onstart(); registerreceiver(arduinoreceiver, new intentfilter(amarinointent.action_received)); amarino.connect(this, device_address); } @override protected void onstop() { super.onstop(); amarino.disconnect(this, device_address); unregisterreceiver(arduinoreceiver); } public class arduinoreceiver extends broadcastreceiver { @override public void onreceive(context context, intent intent) { string data = null; final int datatype = intent.getintextra(amarinointent.extra_data_type, -1); if (datatype == amarinointent.string_extra){ data = intent.getstringextra(amarinointent.extra_data); if (data != null){ mvaluetv.settext(data); try { final int sensorreading = integer.parseint(data); mgraph.adddatapoint(sensorreading); } catch (numberformatexception e) { /* oh data not integer */ } } } } } }
and main.xml
<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <edu.mit.media.hlt.sensorgraph.graphview android:id="@+id/graph" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="4" /> <textview android:id="@+id/value" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="6" android:text="@string/hello" android:textsize="40sp" android:gravity="center" android:background="#fff" /> </linearlayout>
and logcat when i'm trying upload on phone
05-14 00:30:56.640: e/androidruntime(29568): fatal exception: main 05-14 00:30:56.640: e/androidruntime(29568): java.lang.noclassdeffounderror: at.abraxas.amarino.amarino 05-14 00:30:56.640: e/androidruntime(29568): @ edu.mit.media.hlt.sensorgraph.sensorgraph.onstart(sensorgraph.java:71) 05-14 00:30:56.640: e/androidruntime(29568): @ android.app.instrumentation.callactivityonstart(instrumentation.java:1167) 05-14 00:30:56.640: e/androidruntime(29568): @ android.app.activity.performstart(activity.java:5216) 05-14 00:30:56.640: e/androidruntime(29568): @ android.app.activitythread.performlaunchactivity(activitythread.java:2073) 05-14 00:30:56.640: e/androidruntime(29568): @ android.app.activitythread.handlelaunchactivity(activitythread.java:2125) 05-14 00:30:56.640: e/androidruntime(29568): @ android.app.activitythread.access$600(activitythread.java:140) 05-14 00:30:56.640: e/androidruntime(29568): @ android.app.activitythread$h.handlemessage(activitythread.java:1227) 05-14 00:30:56.640: e/androidruntime(29568): @ android.os.handler.dispatchmessage(handler.java:99) 05-14 00:30:56.640: e/androidruntime(29568): @ android.os.looper.loop(looper.java:137) 05-14 00:30:56.640: e/androidruntime(29568): @ android.app.activitythread.main(activitythread.java:4898) 05-14 00:30:56.640: e/androidruntime(29568): @ java.lang.reflect.method.invokenative(native method) 05-14 00:30:56.640: e/androidruntime(29568): @ java.lang.reflect.method.invoke(method.java:511) 05-14 00:30:56.640: e/androidruntime(29568): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:1006) 05-14 00:30:56.640: e/androidruntime(29568): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:773) 05-14 00:30:56.640: e/androidruntime(29568): @ dalvik.system.nativestart.main(native method)
thanks helping me.
this common, had same trouble today. solved creating folder libs in project , adding amarinolibrary's jar folder instead of add external jar. after worked fine. hope you:).
Comments
Post a Comment