modbus android application eclipse - android

I am new at android. I am trying to run java code program of modbusdroid in eclipse
i did not change any code only downloaded latest version seroUtils.jar and added to project because it was missing. error log is attached please help me
when i run it in eclipse
source - https://github.com/bigcat/ModbusDroid
09-25 17:22:17.806: E/dalvikvm(813): Could not find class 'com.bencatlin.modbusdroid.OldVersion.MbDroidMsgExceptionHandler', referenced from method com.bencatlin.modbusdroid.OldVersion.ModbusDroid.onCreate
09-25 17:22:19.117: E/dalvikvm(813): Could not find class 'com.serotonin.util.queue.ByteQueue', referenced from method com.serotonin.modbus4j.base.ModbusUtils.calculateCRC
09-25 17:22:20.277: E/dalvikvm(813): Could not find class 'com.serotonin.messaging.StreamTransport', referenced from method com.serotonin.modbus4j.ip.tcp.TcpMaster.openConnection
09-25 17:22:20.498: E/dalvikvm(813): Could not find class 'com.serotonin.modbus4j.ip.encap.EncapMessageParser', referenced from method com.serotonin.modbus4j.ip.tcp.TcpMaster.init
09-25 17:22:20.667: E/dalvikvm(813): Could not find class 'com.serotonin.modbus4j.ip.xa.XaMessageParser', referenced from method com.serotonin.modbus4j.ip.tcp.TcpMaster.init
09-25 17:22:20.807: E/dalvikvm(813): Could not find class 'com.serotonin.modbus4j.ip.encap.EncapMessageRequest', referenced from method com.serotonin.modbus4j.ip.tcp.TcpMaster.send
09-25 17:22:20.930: E/dalvikvm(813): Could not find class 'com.serotonin.modbus4j.ip.xa.XaMessageRequest', referenced from method com.serotonin.modbus4j.ip.tcp.TcpMaster.send
09-25 17:22:21.437: E/dalvikvm(813): Could not find class 'com.serotonin.messaging.MessageControl', referenced from method com.serotonin.modbus4j.ModbusMaster.getMessageControl
09-25 17:22:21.797: E/dalvikvm(813): Could not find class 'com.serotonin.messaging.DefaultMessagingExceptionHandler', referenced from method com.serotonin.modbus4j.Modbus.<init>
09-25 17:22:22.002: E/dalvikvm(813): Could not find class 'com.serotonin.messaging.DefaultMessagingExceptionHandler', referenced from method com.serotonin.modbus4j.Modbus.setExceptionHandler
09-25 17:22:22.277: E/AndroidRuntime(813): FATAL EXCEPTION: main
09-25 17:22:22.277: E/AndroidRuntime(813): java.lang.NoClassDefFoundError: com.serotonin.messaging.DefaultMessagingExceptionHandler
09-25 17:22:22.277: E/AndroidRuntime(813): at com.serotonin.modbus4j.Modbus.<init>(Modbus.java:34)
09-25 17:22:22.277: E/AndroidRuntime(813): at com.serotonin.modbus4j.ModbusMaster.<init>(ModbusMaster.java:55)
09-25 17:22:22.277: E/AndroidRuntime(813): at com.serotonin.modbus4j.ip.tcp.TcpMaster.<init>(TcpMaster.java:55)
09-25 17:22:22.277: E/AndroidRuntime(813): at com.bencatlin.modbusdroid.OldVersion.ModbusTCPMaster.<init>(ModbusTCPMaster.java:23)
09-25 17:22:22.277: E/AndroidRuntime(813): at com.bencatlin.modbusdroid.OldVersion.ModbusTCPFactory.createModbusTCPMaster(ModbusTCPFactory.java:12)
09-25 17:22:22.277: E/AndroidRuntime(813): at com.bencatlin.modbusdroid.OldVersion.ModbusDroid.onCreate(ModbusDroid.java:426)
09-25 17:22:22.277: E/AndroidRuntime(813): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
09-25 17:22:22.277: E/AndroidRuntime(813): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
09-25 17:22:22.277: E/AndroidRuntime(813): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
09-25 17:22:22.277: E/AndroidRuntime(813): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
09-25 17:22:22.277: E/AndroidRuntime(813): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
09-25 17:22:22.277: E/AndroidRuntime(813): at android.os.Handler.dispatchMessage(Handler.java:99)
09-25 17:22:22.277: E/AndroidRuntime(813): at android.os.Looper.loop(Looper.java:123)
09-25 17:22:22.277: E/AndroidRuntime(813): at android.app.ActivityThread.main(ActivityThread.java:4627)
09-25 17:22:22.277: E/AndroidRuntime(813): at java.lang.reflect.Method.invokeNative(Native Method)
09-25 17:22:22.277: E/AndroidRuntime(813): at java.lang.reflect.Method.invoke(Method.java:521)
09-25 17:22:22.277: E/AndroidRuntime(813): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
09-25 17:22:22.277: E/AndroidRuntime(813): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
09-25 17:22:22.277: E/AndroidRuntime(813): at dalvik.system.NativeStart.main(Native Method)

Display.getRotation was added in Api level 8 (Froyo 2.2 ). I guess you are using a older device or emulator. Create a new AVD with api level >= 8

I had the same problem, I solved putting a new seroutils.jar into the 'libraries' tab into 'java build path' and then I've checked the jar into the 'order and export' tab.
It solves the problem permanently.

Related

My app freezes crashes when it's supposed to go to the next activity

I don't know why the app crashes whenever it's supposed to go to the next Activity. I made a practice app that works as it should when using the same format. I uploaded the files to gist.github.
The error is
1216-1216/com.example.chiozokamalu.newfreshstart E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.ArrayIndexOutOfBoundsException
at com.example.chiozokamalu.newfreshstart.MainActivity.onClick(MainActivity.java:164)
at android.view.View.performClick(View.java:2485)
at android.view.View$PerformClick.run(View.java:9080)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3683)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
at dalvik.system.NativeStart.main(Native Method)
On line 164 of MainActivity.java:
questionView.setText(questions[questionIndex]); // set the text to the next question
EDIT: After Varun helped me, I get a new error which is
1307-1307/com.example.chiozokamalu.newfreshstart E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.chiozokamalu.newfreshstart/com.example.chiozokamalu.newfreshstart.Results1}: java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
at android.app.ActivityThread.access$1500(ActivityThread.java:117)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3683)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at com.example.chiozokamalu.newfreshstart.Results1.onCreate(Results1.java:58)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
            at android.app.ActivityThread.access$1500(ActivityThread.java:117)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
            at android.os.Handler.dispatchMessage(Handler.java:99)
            at android.os.Looper.loop(Looper.java:130)
            at android.app.ActivityThread.main(ActivityThread.java:3683)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:507)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
            at dalvik.system.NativeStart.main(Native Method)
The questions array at line no. 164 is going out of bound that means questionIndex is greater than the total length of the questions array. So you should add a check on the length before extracting value from the array.
You have added the check but after that you incremented the value so either you modify the if condition to if (questionIndex < questions.length -1)
or modify the questionIndex variable before the if condition
You are getting problem because you haven't initiated resultView9 that is why it is null and giving nullpointer, just initiatlise it as you done with other and everything is fine. You have initialised the resultView8 twice just add resultview9 over there

Could not find class 'android.app.Notification$Builder

I have add into my project's libralies the andriod-support-v4.jar... but I am getting this error:
Could not find class 'android.app.Notification$Builder', referenced from method org.secure.sms.SmsReceiver.showNotification
Could not find class 'android.support.v4.app.NotificationCompat$Builder', referenced from method org.secure.sms.SmsReceiver.createNotification
FATAL EXCEPTION: main
java.lang.NoClassDefFoundError: android.support.v4.app.NotificationCompat$Builder
at org.secure.sms.SmsReceiver.createNotification(SmsReceiver.java:108)
at org.secure.sms.SmsReceiver.onReceive(SmsReceiver.java:136)
at android.app.ActivityThread.handleReceiver(ActivityThread.java:1794)
at android.app.ActivityThread.access$2400(ActivityThread.java:117)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:981)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:3683)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
at dalvik.system.NativeStart.main(Native Method)
Where is the problem??
Screenshot: http://i.stack.imgur.com/I95ke.jpg
be sure to have android-support-v4.jar inside your folder /libs
and add this to your class:
import android.support.v4.app.NotificationCompat;

App crashes by Resource$NotFoundException using ActionBarSherlock

My application crashes on start up with this log:
09-25 07:12:27.721: W/ResourceType(361): Failure getting entry for 0x7f030016 (t=2 e=22) in package 0: 0xffffffb5
09-25 07:12:27.721: D/AndroidRuntime(361): Shutting down VM
09-25 07:12:27.721: W/dalvikvm(361): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
09-25 07:12:27.741: E/AndroidRuntime(361): FATAL EXCEPTION: main
09-25 07:12:27.741: E/AndroidRuntime(361): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.villaparvaneh/com.villaparvaneh.VillaListActivity}: android.content.res.Resources$NotFoundException: Resource ID #0x7f030016
09-25 07:12:27.741: E/AndroidRuntime(361): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
09-25 07:12:27.741: E/AndroidRuntime(361): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
09-25 07:12:27.741: E/AndroidRuntime(361): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
09-25 07:12:27.741: E/AndroidRuntime(361): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
09-25 07:12:27.741: E/AndroidRuntime(361): at android.os.Handler.dispatchMessage(Handler.java:99)
09-25 07:12:27.741: E/AndroidRuntime(361): at android.os.Looper.loop(Looper.java:123)
09-25 07:12:27.741: E/AndroidRuntime(361): at android.app.ActivityThread.main(ActivityThread.java:4627)
09-25 07:12:27.741: E/AndroidRuntime(361): at java.lang.reflect.Method.invokeNative(Native Method)
09-25 07:12:27.741: E/AndroidRuntime(361): at java.lang.reflect.Method.invoke(Method.java:521)
09-25 07:12:27.741: E/AndroidRuntime(361): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
09-25 07:12:27.741: E/AndroidRuntime(361): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
09-25 07:12:27.741: E/AndroidRuntime(361): at dalvik.system.NativeStart.main(Native Method)
09-25 07:12:27.741: E/AndroidRuntime(361): Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x7f030016
09-25 07:12:27.741: E/AndroidRuntime(361): at android.content.res.Resources.getValue(Resources.java:892)
09-25 07:12:27.741: E/AndroidRuntime(361): at android.content.res.Resources.loadXmlResourceParser(Resources.java:1869)
09-25 07:12:27.741: E/AndroidRuntime(361): at android.content.res.Resources.getLayout(Resources.java:731)
09-25 07:12:27.741: E/AndroidRuntime(361): at android.view.LayoutInflater.inflate(LayoutInflater.java:318)
09-25 07:12:27.741: E/AndroidRuntime(361): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
09-25 07:12:27.741: E/AndroidRuntime(361): at com.actionbarsherlock.internal.ActionBarSherlockCompat.setContentView(ActionBarSherlockCompat.java:840)
09-25 07:12:27.741: E/AndroidRuntime(361): at com.actionbarsherlock.app.SherlockFragmentActivity.setContentView(SherlockFragmentActivity.java:261)
09-25 07:12:27.741: E/AndroidRuntime(361): at com.villaparvaneh.VillaListActivity.onCreate(VillaListActivity.java:47)
09-25 07:12:27.741: E/AndroidRuntime(361): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
09-25 07:12:27.741: E/AndroidRuntime(361): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
09-25 07:12:27.741: E/AndroidRuntime(361): ... 11 more
At first I used eclipse wizard for creating a Master/Detail activity and my minsdk was set to 11. but then I used ActionBarSherlock and changed my activity code for that nothing more! At first time lunch there was an error for not setting theme to Theme.Sherlock.Light. after I changed the style file the above error comes up!
I googled for a day and read some similar issues like this and this, but it seems that my problem is not related to them. I searched for resource 0x7f030016 in R.java file and find out that it is R.attr.actionModeCloseDrawable and the exception is thrown in the setContentView(int layoutResId) of ActionBarSherlockCompat.java or ActionBarSherlockNative.java at the following line:
mActivity.getLayoutInflater().inflate(layoutResId, mContentParent);
where layoutResId is R.attr.actionModeCloseDrawable and mContentParent is an instance of com.actionbarsherlock.internal.nineoldandroids.widget.NineFrameLayout. I spend a whole day on this and checked every related link on google, but I cant figure out what's happening. I use Android 4.3 for building the app and support library revision 18. I don't think my code is useful here because error is not happened in my code. maybe some of xml files in res folder is needed, just tell which one to add it.
Any idea?
Thanks

android VerifyError

i'm getting this message when i run my application i don't know why i'm getting it could any one help me. here is the logcat.
java.lang.VerifyError: com.kosh.me.Smaller
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1429)
at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2577)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
at android.app.ActivityThread.access$2300(ActivityThread.java:125)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4627)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:876)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:634)
at dalvik.system.NativeStart.main(Native Method)
This happens when the build library classes conflict with those at run-time. Try performing a Clean of your project followed by a build.

Android App crashes when rotate

I put the following code in my manifest.xml
<activity android:name="CPohonApp" android:configChanges="keyboardHidden|orientation"></activity>
and this is the code in my activity
#Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
}
but still the App crashes when I rotate.
Why does this happen?
I use Android 2.3.3 API 10
thank you
EDIT
this is my log cat
09-25 14:36:31.351: E/AndroidRuntime(334): FATAL EXCEPTION: main
09-25 14:36:31.351: E/AndroidRuntime(334): java.lang.RuntimeException: Unable to start activity ComponentInfo{org.hdte.sawit/org.hdte.sawit.pohon.CPohonApp}: java.lang.NullPointerException
09-25 14:36:31.351: E/AndroidRuntime(334): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
09-25 14:36:31.351: E/AndroidRuntime(334): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
09-25 14:36:31.351: E/AndroidRuntime(334): at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:2832)
09-25 14:36:31.351: E/AndroidRuntime(334): at android.app.ActivityThread.access$1600(ActivityThread.java:117)
09-25 14:36:31.351: E/AndroidRuntime(334): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
09-25 14:36:31.351: E/AndroidRuntime(334): at android.os.Handler.dispatchMessage(Handler.java:99)
09-25 14:36:31.351: E/AndroidRuntime(334): at android.os.Looper.loop(Looper.java:123)
09-25 14:36:31.351: E/AndroidRuntime(334): at android.app.ActivityThread.main(ActivityThread.java:3683)
09-25 14:36:31.351: E/AndroidRuntime(334): at java.lang.reflect.Method.invokeNative(Native Method)
09-25 14:36:31.351: E/AndroidRuntime(334): at java.lang.reflect.Method.invoke(Method.java:507)
09-25 14:36:31.351: E/AndroidRuntime(334): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
09-25 14:36:31.351: E/AndroidRuntime(334): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
09-25 14:36:31.351: E/AndroidRuntime(334): at dalvik.system.NativeStart.main(Native Method)
09-25 14:36:31.351: E/AndroidRuntime(334): Caused by: java.lang.NullPointerException
09-25 14:36:31.351: E/AndroidRuntime(334): at org.hdte.sawit.pohon.CPohonApp.createDialogSend(CPohonApp.java:277)
09-25 14:36:31.351: E/AndroidRuntime(334): at org.hdte.sawit.pohon.CPohonApp.onCreateDialog(CPohonApp.java:299)
09-25 14:36:31.351: E/AndroidRuntime(334): at android.app.Activity.onCreateDialog(Activity.java:2482)
09-25 14:36:31.351: E/AndroidRuntime(334): at android.app.Activity.createDialog(Activity.java:882)
09-25 14:36:31.351: E/AndroidRuntime(334): at android.app.Activity.restoreManagedDialogs(Activity.java:871)
09-25 14:36:31.351: E/AndroidRuntime(334): at android.app.Activity.performRestoreInstanceState(Activity.java:817)
09-25 14:36:31.351: E/AndroidRuntime(334): at android.app.Instrumentation.callActivityOnRestoreInstanceState(Instrumentation.java:1096)
09-25 14:36:31.351: E/AndroidRuntime(334): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1625)
09-25 14:36:31.351: E/AndroidRuntime(334): ... 12 more
You should you Dot(.) leading your activity Name.
<activity android:name=".CPohonApp" android:configChanges="keyboardHidden|orientation"></activity>
Or use full package name with your activity name when you declare it in android manifest file.
<activity android:name="yourpackagename.CPohonApp" android:configChanges="keyboardHidden|orientation"></activity>
Use in each Activity tag
<activity android:name=".example" android:configChanges="orientation|keyboardHidden"/>
add this code in manifest
android:configChanges="orientation|keyboardHidden|screenSize"
full code example
<activity
android:name=".your activity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="#string/app_name" >
</activity>

Categories

Resources