|
|
Connecting Android and Arduino
created on Apr 26, 2012 4:55:17 AM
Hello guys, I'm new to android app development. By referring to source code developed by few people at Amarino website, I'm trying to develop my own app for controlling a LED using my Android phone. There are 3 activities in my class. First activity just includes a button and on clicking it it goes to 2nd activity. In 2nd activity we are asked to enter bluetooth ID and on pressing the next button it has to connect with the bluetooth device. But the app crashes. And in the 3rd activity the following code is showing error, which I'm not able to rectify it! 1private ArduinoReceiver arduinoReceiver = new ArduinoReceiver();
Please help. Thanks in advance.
|
|
|
RE: Connecting Android and Arduino
created on Apr 26, 2012 6:45:26 AM
Can you paste the logcat for when the app crashes? And what is the error are you getting on private ArduinoReceiver arduinoReceiver = new ArduinoReceiver();
|
|
|
RE: Connecting Android and Arduino
created on Apr 26, 2012 7:40:38 AM
04-26 11:09:16.434: W/dalvikvm(471): threadid=1: thread exiting with uncaught exception (group=0x40015560) 04-26 11:09:16.444: E/AndroidRuntime(471): FATAL EXCEPTION: main 04-26 11:09:16.444: E/AndroidRuntime(471): java.lang.NoClassDefFoundError: at.abraxas.amarino.Amarino 04-26 11:09:16.444: E/AndroidRuntime(471): at com.sabarish.lightcontrol.secondID.onClick(secondID.java:34) 04-26 11:09:16.444: E/AndroidRuntime(471): at android.view.View.performClick(View.java:2485) 04-26 11:09:16.444: E/AndroidRuntime(471): at android.view.View$PerformClick.run(View.java:9080) 04-26 11:09:16.444: E/AndroidRuntime(471): at android.os.Handler.handleCallback(Handler.java:587) 04-26 11:09:16.444: E/AndroidRuntime(471): at android.os.Handler.dispatchMessage(Handler.java:92) 04-26 11:09:16.444: E/AndroidRuntime(471): at android.os.Looper.loop(Looper.java:123) 04-26 11:09:16.444: E/AndroidRuntime(471): at android.app.ActivityThread.main(ActivityThread.java:3683) 04-26 11:09:16.444: E/AndroidRuntime(471): at java.lang.reflect.Method.invokeNative(Native Method) 04-26 11:09:16.444: E/AndroidRuntime(471): at java.lang.reflect.Method.invoke(Method.java:507) 04-26 11:09:16.444: E/AndroidRuntime(471): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839) 04-26 11:09:16.444: E/AndroidRuntime(471): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597) 04-26 11:09:16.444: E/AndroidRuntime(471): at dalvik.system.NativeStart.main(Native Method)
|
|
|
RE: Connecting Android and Arduino
created on Apr 26, 2012 7:41:59 AM
arduinoReceiver = new ArduinoReceiver();
I'm getting the error: ArduinoReceiver cannot be resolved to a type.
|
|
|
RE: Connecting Android and Arduino
created on Apr 26, 2012 6:44:24 PM
Sabarish 04-26 11:09:16.434: W/dalvikvm(471): threadid=1: thread exiting with uncaught exception (group=0x40015560) 04-26 11:09:16.444: E/AndroidRuntime(471): FATAL EXCEPTION: main 04-26 11:09:16.444: E/AndroidRuntime(471): java.lang.NoClassDefFoundError: at.abraxas.amarino.Amarino 04-26 11:09:16.444: E/AndroidRuntime(471): at com.sabarish.lightcontrol.secondID.onClick(secondID.java:34) 04-26 11:09:16.444: E/AndroidRuntime(471): at android.view.View.performClick(View.java:2485) 04-26 11:09:16.444: E/AndroidRuntime(471): at android.view.View$PerformClick.run(View.java:9080) 04-26 11:09:16.444: E/AndroidRuntime(471): at android.os.Handler.handleCallback(Handler.java:587) 04-26 11:09:16.444: E/AndroidRuntime(471): at android.os.Handler.dispatchMessage(Handler.java:92) 04-26 11:09:16.444: E/AndroidRuntime(471): at android.os.Looper.loop(Looper.java:123) 04-26 11:09:16.444: E/AndroidRuntime(471): at android.app.ActivityThread.main(ActivityThread.java:3683) 04-26 11:09:16.444: E/AndroidRuntime(471): at java.lang.reflect.Method.invokeNative(Native Method) 04-26 11:09:16.444: E/AndroidRuntime(471): at java.lang.reflect.Method.invoke(Method.java:507) 04-26 11:09:16.444: E/AndroidRuntime(471): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839) 04-26 11:09:16.444: E/AndroidRuntime(471): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597) 04-26 11:09:16.444: E/AndroidRuntime(471): at dalvik.system.NativeStart.main(Native Method) This is an easy one, it usually means that you have not declared the activity your trying to open in your manifest.xml file. You need to add: <activity android:name="Amarino" android:label="@string/app_name" > </activity> To the mainfest.xml file of your project before the </application> tag.
|
|
|
RE: Connecting Android and Arduino
created on Apr 26, 2012 6:49:33 PM
Sabarish arduinoReceiver = new ArduinoReceiver();
I'm getting the error: ArduinoReceiver cannot be resolved to a type. When it says it can't be resolved to a type, it probably because your not importing it; and therefore does not know what Arduino is. At the top of your code before the public class activity extends Activity You need to put: import ArduinoPackageName; Where ArduinoPackageName would = the full package name for whatever Arduino code your using.
|
|
|
RE: Connecting Android and Arduino
created on Apr 27, 2012 5:03:18 AM
Jeremiah Sabarish arduinoReceiver = new ArduinoReceiver();
I'm getting the error: ArduinoReceiver cannot be resolved to a type. When it says it can't be resolved to a type, it probably because your not importing it; and therefore does not know what Arduino is. At the top of your code before the public class activity extends Activity You need to put: import ArduinoPackageName; Where ArduinoPackageName would = the full package name for whatever Arduino code your using. I've imported all the files. The code which i'm referring to isn't showing that error but my code is showing that error!
|
|
|
RE: Connecting Android and Arduino
created on Apr 27, 2012 8:23:08 AM
i have already declared the activity in Android Manifest and when I call the activity, it force closes.
|
|
|
RE: Connecting Android and Arduino
created on Apr 28, 2012 2:46:42 AM
Sabarish i have already declared the activity in Android Manifest and when I call the activity, it force closes. Ok, i see now what the problem is, this line is telling you: 04-26 11:09:16.444: E/AndroidRuntime(471): at com.sabarish.lightcontrol.secondID.onClick(secondID.java:34) Take a look at line 34 in your secondID.java file, there is a problem in the onClick method.
|
|
|
RE: Connecting Android and Arduino
created on Apr 28, 2012 1:07:00 PM
— modified on Apr 28, 2012 1:07:52 PM
Jeremiah Sabarish i have already declared the activity in Android Manifest and when I call the activity, it force closes. Ok, i see now what the problem is, this line is telling you: 04-26 11:09:16.444: E/AndroidRuntime(471): at com.sabarish.lightcontrol.secondID.onClick(secondID.java:34) Take a look at line 34 in your secondID.java file, there is a problem in the onClick method. can you help me figuring out the problem? 1package com.sabarish.lightcontrol; 2 3import android.app.Activity; 4import android.content.Intent; 5import android.os.Bundle; 6import android.view.View; 7import android.view.View.OnClickListener; 8import android.widget.Button; 9import android.widget.EditText; 10import at.abraxas.amarino.Amarino; 11 12public class secondID extends Activity implements OnClickListener{ 13 14 Button proceed; 15 EditText bluID; 16 String deviceID; 17 18 @Override 19 protected void onCreate(Bundle savedInstanceState) { 20 super.onCreate(savedInstanceState); 21 setContentView(R.layout.second); 22 23 proceed = (Button) findViewById(R.id.bluID); 24 bluID = (EditText) findViewById(R.id.BLUidTEXT); 25 26 proceed.setOnClickListener(this); 27 } 28 29 public void onClick(View v) 30 { 31 deviceID = bluID.getText().toString(); 32 Amarino.connect(this, deviceID); 33 Intent i = new Intent("com.sabarish.lightcontrol.LIGHTMAIN"); 34 startActivity(i); 35 } 36}
|
|
|
RE: Connecting Android and Arduino
created on Apr 28, 2012 9:40:10 PM
Is "com.sabarish.lightcontrol.LIGHTMAIN" part of the same app or is this another app?
Make sure your declaring this acitivy in your manifest...
<activity android:name=".LIGHTMAIN"></activity>
Make sure it's outside other activity and in application.
|
|
|
RE: Connecting Android and Arduino
created on Apr 30, 2012 3:21:58 PM
Jeremiah Is "com.sabarish.lightcontrol.LIGHTMAIN" part of the same app or is this another app?
Make sure your declaring this acitivy in your manifest...
<activity android:name=".LIGHTMAIN"></activity>
Make sure it's outside other activity and in application. chk out my manifest. I can't find any error! 1<?xml version="1.0" encoding="utf-8"?> 2<manifest xmlns:android="http://schemas.android.com/apk/res/android" 3 package="com.sabarish.lightcontrol" android:versionCode="1" 4 android:versionName="1.0"> 5 6 <uses-sdk android:minSdkVersion="8" /> 7 8 <application android:icon="@drawable/ic_launcher" 9 android:label="@string/app_name" android:debuggable="true"> 10 <activity android:name=".Main" android:label="@string/app_name"> 11 <intent-filter> 12 <action android:name="android.intent.action.MAIN" /> 13 14 <category android:name="android.intent.category.LAUNCHER" /> 15 </intent-filter> 16 </activity> 17 <activity android:name=".secondID" android:label="@string/app_name"> 18 <intent-filter> 19 <action android:name="com.sabarish.lightcontrol.SECONDID" /> 20 21 <category android:name="android.intent.category.DEFAULT" /> 22 </intent-filter> 23 </activity> 24 <activity android:name=".lightmain" android:label="@string/app_name"> 25 <intent-filter> 26 <action android:name="com.sabarish.lightcontrol.LIGHTMAIN" /> 27 28 <category android:name="android.intent.category.DEFAULT" /> 29 </intent-filter> 30 </activity> 31 32 </application> 33 34</manifest>
|
|
|
RE: Connecting Android and Arduino
created on Apr 30, 2012 6:57:59 PM
— modified on Apr 30, 2012 6:59:34 PM
Change : <activity android:name=".lightmain" to : <activity android:name=".LIGHTMAIN" an see what happens ... Btw. in Java you're always operating case-sensitive ...
-----
lg Voss - Ach ja und noch was, die AndroidPIT-Regeln ლ(╹◡╹ლ) Android Security
|
|
|
RE: Connecting Android and Arduino
created on May 1, 2012 1:14:29 PM
The problem was that I didn't define seekbarchangelistener method in lightmain class.
Thanks a lot for the help.
|
|
|
RE: Connecting Android and Arduino
created on May 1, 2012 9:42:11 PM
Sabarish The problem was that I didn't define seekbarchangelistener method in lightmain class.
Thanks a lot for the help. Glad we could help
|
|
|
RE: Connecting Android and Arduino
created on May 2, 2012 3:30:24 PM
— modified on May 2, 2012 3:31:02 PM
Jeremiah and Jorg = beasts :-D
|