I am trying to setup barcode scanner for an android app. I was able to setup the barcode scanner using the plugin provided by phonegap. That worked fine on some phones but was not working on some HTC phones. I searched online and some one suggested that upgrading to zxing 2.0 should solve the problem. So, I downloaded the zxing-2.0 and followed the following steps:
1. Unzipped the zxing-2.0 and built the core package.
2. Added the android package to eclipse as an Android Project and selected it as library( named zxing-2 ).
3. Added core.jar as an external jar to the zxing-2 which made it build successfully on eclipse.
4. Added the zxing-2 as project dependency of my main app(myApp). Also added core.jar as an external jar in myApp.
MyApp's mainfest.xml now contains( earlier it contained the action name as com.phonegap.plugins.barcodescanner.SCAN):
<activity android:name="com.google.zxing.client.android.CaptureActivity"
android:screenOrientation="landscape"
android:configChanges="orientation|keyboardHidden"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
android:windowSoftInputMode="stateAlwaysHidden">
<intent-filter>
<action android:name="com.google.zxing.client.android.SCAN"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
<activity android:name="com.google.zxing.client.android.encode.EncodeActivity"
android:label="#string/share_name">
<intent-filter>
<action android:name="com.google.zxing.client.android.ENCODE"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
I am using the BarcodeScanner.java provided in phone gap plugin to invoke the barcode scanner. I changed the scan() method in it to:
//new version
public void scan() {
Intent intentScan = new Intent("com.google.zxing.client.android.SCAN");
intentScan.addCategory(Intent.CATEGORY_DEFAULT);
this.ctx.startActivityForResult((Plugin) this, intentScan, REQUEST_CODE);
}
//earlier version(it worked with zxing 1.7)
public void scan() {
Intent intentScan = new Intent("com.phonegap.plugins.barcodescanner.SCAN");
intentScan.addCategory(Intent.CATEGORY_DEFAULT);
this.ctx.startActivityForResult((Plugin) this, intentScan, REQUEST_CODE);
}
The project builds fine but when I run it and trigger the scan, I get the following runtime exception:
03-03 19:43:13.499: E/AndroidRuntime(276): FATAL EXCEPTION: main
03-03 19:43:13.499: E/AndroidRuntime(276): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.phonegap.myApp/com.google.zxing.client.android.CaptureActivity}: android.view.InflateException: Binary XML file line #2: Error inflating class phonegap
03-03 19:43:13.499: E/AndroidRuntime(276): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
03-03 19:43:13.499: E/AndroidRuntime(276): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
03-03 19:43:13.499: E/AndroidRuntime(276): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
03-03 19:43:13.499: E/AndroidRuntime(276): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
03-03 19:43:13.499: E/AndroidRuntime(276): at android.os.Handler.dispatchMessage(Handler.java:99)
03-03 19:43:13.499: E/AndroidRuntime(276): at android.os.Looper.loop(Looper.java:123)
03-03 19:43:13.499: E/AndroidRuntime(276): at android.app.ActivityThread.main(ActivityThread.java:4627)
03-03 19:43:13.499: E/AndroidRuntime(276): at java.lang.reflect.Method.invokeNative(Native Method)
03-03 19:43:13.499: E/AndroidRuntime(276): at java.lang.reflect.Method.invoke(Method.java:521)
03-03 19:43:13.499: E/AndroidRuntime(276): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
03-03 19:43:13.499: E/AndroidRuntime(276): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
03-03 19:43:13.499: E/AndroidRuntime(276): at dalvik.system.NativeStart.main(Native Method)
03-03 19:43:13.499: E/AndroidRuntime(276): Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class phonegap
03-03 19:43:13.499: E/AndroidRuntime(276): at android.preference.GenericInflater.createItemFromTag(GenericInflater.java:441)
03-03 19:43:13.499: E/AndroidRuntime(276): at android.preference.GenericInflater.inflate(GenericInflater.java:317)
03-03 19:43:13.499: E/AndroidRuntime(276): at android.preference.GenericInflater.inflate(GenericInflater.java:263)
03-03 19:43:13.499: E/AndroidRuntime(276): at android.preference.PreferenceManager.inflateFromResource(PreferenceManager.java:251)
03-03 19:43:13.499: E/AndroidRuntime(276): at android.preference.PreferenceManager.setDefaultValues(PreferenceManager.java:444)
03-03 19:43:13.499: E/AndroidRuntime(276): at android.preference.PreferenceManager.setDefaultValues(PreferenceManager.java:422)
03-03 19:43:13.499: E/AndroidRuntime(276): at com.google.zxing.client.android.CaptureActivity.onCreate(CaptureActivity.java:167)
03-03 19:43:13.499: E/AndroidRuntime(276): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
03-03 19:43:13.499: E/AndroidRuntime(276): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
03-03 19:43:13.499: E/AndroidRuntime(276): ... 11 more
03-03 19:43:13.499: E/AndroidRuntime(276): Caused by: java.lang.ClassNotFoundException: android.preference.phonegap in loader dalvik.system.PathClassLoader[/data/app/com.phonegap.myApp-1.apk]
03-03 19:43:13.499: E/AndroidRuntime(276): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
03-03 19:43:13.499: E/AndroidRuntime(276): at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
03-03 19:43:13.499: E/AndroidRuntime(276): at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
03-03 19:43:13.499: E/AndroidRuntime(276): at android.preference.GenericInflater.createItem(GenericInflater.java:375)
03-03 19:43:13.499: E/AndroidRuntime(276): at android.preference.GenericInflater.onCreateItem(GenericInflater.java:417)
03-03 19:43:13.499: E/AndroidRuntime(276): at android.preference.GenericInflater.createItemFromTag(GenericInflater.java:428)
03-03 19:43:13.499: E/AndroidRuntime(276): ... 19 more
Can someone help me figure out what I am doing wrong here or have I missed something.
Thanks.
Your major problem is that you are trying to integrate by Intent, but are also including core/ and android/. You should never use android/ like this, and only use core/ if building your own internal scanning. Remove these entirely.
All you want from the project is android-integration/ and all you need to do is here: http://code.google.com/p/zxing/wiki/ScanningViaIntent
I don't know Phonegap well, but it's not worth using it on Android for this.
Related
I just want to make sure I'm understanding the method to setup for multiple screen.
I want to make the app runnable from API 8-21.
So far, I implemented smallest-width to differentiate the multiple screen. Everything works perfectly in the emulator when I use API 17, but crashes when i use API 8. I then realized that smallest-width only works for API 13 and above.
So now, I think my next step is to just create layout-small, layout-normal, etc. and adjust it for them.
Is this the correct way to tackle the problem?
Edit***********
Here's the logcat from the error filter, let me know if I need to post the other:
11-19 05:28:37.769: E/AndroidRuntime(276): FATAL EXCEPTION: main
11-19 05:28:37.769: E/AndroidRuntime(276): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.nah.ace/com.nah.ace.MainActivity}: android.content.res.Resources$NotFoundException: Resource ID #0x7f030018
11-19 05:28:37.769: E/AndroidRuntime(276): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
11-19 05:28:37.769: E/AndroidRuntime(276): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
11-19 05:28:37.769: E/AndroidRuntime(276): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
11-19 05:28:37.769: E/AndroidRuntime(276): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
11-19 05:28:37.769: E/AndroidRuntime(276): at android.os.Handler.dispatchMessage(Handler.java:99)
11-19 05:28:37.769: E/AndroidRuntime(276): at android.os.Looper.loop(Looper.java:123)
11-19 05:28:37.769: E/AndroidRuntime(276): at android.app.ActivityThread.main(ActivityThread.java:4627)
11-19 05:28:37.769: E/AndroidRuntime(276): at java.lang.reflect.Method.invokeNative(Native Method)
11-19 05:28:37.769: E/AndroidRuntime(276): at java.lang.reflect.Method.invoke(Method.java:521)
11-19 05:28:37.769: E/AndroidRuntime(276): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
11-19 05:28:37.769: E/AndroidRuntime(276): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
11-19 05:28:37.769: E/AndroidRuntime(276): at dalvik.system.NativeStart.main(Native Method)
11-19 05:28:37.769: E/AndroidRuntime(276): Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x7f030018
11-19 05:28:37.769: E/AndroidRuntime(276): at android.content.res.Resources.getValue(Resources.java:892)
11-19 05:28:37.769: E/AndroidRuntime(276): at android.content.res.Resources.loadXmlResourceParser(Resources.java:1869)
11-19 05:28:37.769: E/AndroidRuntime(276): at android.content.res.Resources.getLayout(Resources.java:731)
11-19 05:28:37.769: E/AndroidRuntime(276): at android.view.LayoutInflater.inflate(LayoutInflater.java:318)
11-19 05:28:37.769: E/AndroidRuntime(276): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
11-19 05:28:37.769: E/AndroidRuntime(276): at android.support.v7.app.ActionBarActivityDelegateBase.setContentView(ActionBarActivityDelegateBase.java:228)
11-19 05:28:37.769: E/AndroidRuntime(276): at android.support.v7.app.ActionBarActivity.setContentView(ActionBarActivity.java:102)
11-19 05:28:37.769: E/AndroidRuntime(276): at com.nah.ace.MainActivity.onCreate(MainActivity.java:18)
11-19 05:28:37.769: E/AndroidRuntime(276): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
11-19 05:28:37.769: E/AndroidRuntime(276): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
11-19 05:28:37.769: E/AndroidRuntime(276): ... 11 more
Also would like to add that my default layout folder is empty. Under API8, it seems like it's trying to load off that folder, instead of layout-sw-320dpi, which is probably the reason for the crash. I tested on API17+API21 and it loads off the layout-sw-320dpi just fine.
Edit2:
Seems to only work on API16+.
Edit3:
My manifest's sdk:
android:minSdkVersion="8"
android:targetSdkVersion="21"
No , problem is caused by due to your java class not by your xml files what I can assume from this point.
Hi im trying to set up a frame animation with a series of images as a background for my splash page in an android application at the moment there is no errors but when I run the application it quits unexpectedly. The first error which follows 10 garbage collections is E/dalvikvm-heap(276): 1234272-byte external allocation too large for this process. I have 17 images I am using for the frame animation each of them are 50k or less so I dont think that the image sizes can be the issue.
The java code I have implemented in my main activity is as follows:
#Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ImageView frameanimation = (ImageView) findViewById(R.id.frame_animation);
AnimationDrawable frame_animation = (AnimationDrawable) frameanimation.getBackground();
frame_animation.setVisible(true, true);
frame_animation.start();
}
I then have this code implementing an image view within my XML Layout file:
<ImageView
android:id="#+id/frame_animation"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:src="#drawable/frame_animation"
android:background="#drawable/frame_animation"/>
and finally I have my animation drawable saved as 'frame_animation.xml' within my drawable folder.
<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android" android:oneshot="false">
<item android:drawable="#drawable/homebckgrnda1" android:duration="200" />
<item android:drawable="#drawable/homebckgrnda2" android:duration="50" />
<item android:drawable="#drawable/homebckgrnda3" android:duration="50" />
<item android:drawable="#drawable/homebckgrnda4" android:duration="50" />
<item android:drawable="#drawable/homebckgrnda5" android:duration="50" />
<item android:drawable="#drawable/homebckgrnda6" android:duration="50" />
<item android:drawable="#drawable/homebckgrnda7" android:duration="50" />
<item android:drawable="#drawable/homebckgrnda8" android:duration="50" />
<item android:drawable="#drawable/homebckgrnda9" android:duration="50" />
<item android:drawable="#drawable/homebckgrnda10" android:duration="50" />
<item android:drawable="#drawable/homebckgrnda11" android:duration="50" />
<item android:drawable="#drawable/homebckgrnda12" android:duration="50" />
<item android:drawable="#drawable/homebckgrnda13" android:duration="50" />
<item android:drawable="#drawable/homebckgrnda14" android:duration="50" />
<item android:drawable="#drawable/homebckgrnda15" android:duration="50" />
<item android:drawable="#drawable/homebckgrnda16" android:duration="50" />
<item android:drawable="#drawable/homebckgrnda17" android:duration="50" />
</animation-list>
The full LogCat log that I get when running the application is shown here:
04-16 13:51:33.703: D/dalvikvm(276): GC_EXTERNAL_ALLOC freed 906 objects / 64688 bytes in 69ms
04-16 13:51:33.983: D/dalvikvm(276): GC_EXTERNAL_ALLOC freed 208 objects / 9952 bytes in 66ms
04-16 13:51:34.203: D/dalvikvm(276): GC_EXTERNAL_ALLOC freed 54 objects / 2112 bytes in 51ms
04-16 13:51:34.443: D/dalvikvm(276): GC_EXTERNAL_ALLOC freed 13 objects / 536 bytes in 52ms
04-16 13:51:34.683: D/dalvikvm(276): GC_EXTERNAL_ALLOC freed 13 objects / 512 bytes in 54ms
04-16 13:51:35.133: D/dalvikvm(276): GC_EXTERNAL_ALLOC freed 20 objects / 824 bytes in 52ms
04-16 13:51:35.593: D/dalvikvm(276): GC_EXTERNAL_ALLOC freed 26 objects / 1216 bytes in 70ms
04-16 13:51:36.023: D/dalvikvm(276): GC_EXTERNAL_ALLOC freed 24 objects / 1008 bytes in 51ms
04-16 13:51:36.394: D/dalvikvm(276): GC_EXTERNAL_ALLOC freed 26 objects / 1128 bytes in 55ms
04-16 13:51:36.803: D/dalvikvm(276): GC_EXTERNAL_ALLOC freed 24 objects / 984 bytes in 50ms
04-16 13:51:37.143: E/dalvikvm-heap(276): 1234272-byte external allocation too large for this process.
04-16 13:51:37.143: E/GraphicsJNI(276): VM won't let us allocate 1234272 bytes
04-16 13:51:37.153: D/AndroidRuntime(276): Shutting down VM
04-16 13:51:37.153: W/dalvikvm(276): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
04-16 13:51:37.203: E/AndroidRuntime(276): FATAL EXCEPTION: main
04-16 13:51:37.203: E/AndroidRuntime(276): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.android.BadmintonTrain/com.android.BadmintonTrain.BadmintonTrainActivity}: android.view.InflateException: Binary XML file line #19: Error inflating class android.widget.ImageView
04-16 13:51:37.203: E/AndroidRuntime(276): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
04-16 13:51:37.203: E/AndroidRuntime(276): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
04-16 13:51:37.203: E/AndroidRuntime(276): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
04-16 13:51:37.203: E/AndroidRuntime(276): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
04-16 13:51:37.203: E/AndroidRuntime(276): at android.os.Handler.dispatchMessage(Handler.java:99)
04-16 13:51:37.203: E/AndroidRuntime(276): at android.os.Looper.loop(Looper.java:123)
04-16 13:51:37.203: E/AndroidRuntime(276): at android.app.ActivityThread.main(ActivityThread.java:4627)
04-16 13:51:37.203: E/AndroidRuntime(276): at java.lang.reflect.Method.invokeNative(Native Method)
04-16 13:51:37.203: E/AndroidRuntime(276): at java.lang.reflect.Method.invoke(Method.java:521)
04-16 13:51:37.203: E/AndroidRuntime(276): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
04-16 13:51:37.203: E/AndroidRuntime(276): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
04-16 13:51:37.203: E/AndroidRuntime(276): at dalvik.system.NativeStart.main(Native Method)
04-16 13:51:37.203: E/AndroidRuntime(276): Caused by: android.view.InflateException: Binary XML file line #19: Error inflating class android.widget.ImageView
04-16 13:51:37.203: E/AndroidRuntime(276): at android.view.LayoutInflater.createView(LayoutInflater.java:513)
04-16 13:51:37.203: E/AndroidRuntime(276): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
04-16 13:51:37.203: E/AndroidRuntime(276): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
04-16 13:51:37.203: E/AndroidRuntime(276): at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
04-16 13:51:37.203: E/AndroidRuntime(276): at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
04-16 13:51:37.203: E/AndroidRuntime(276): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
04-16 13:51:37.203: E/AndroidRuntime(276): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
04-16 13:51:37.203: E/AndroidRuntime(276): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:198)
04-16 13:51:37.203: E/AndroidRuntime(276): at android.app.Activity.setContentView(Activity.java:1647)
04-16 13:51:37.203: E/AndroidRuntime(276): at com.android.BadmintonTrain.BadmintonTrainActivity.onCreate(BadmintonTrainActivity.java:21)
04-16 13:51:37.203: E/AndroidRuntime(276): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
04-16 13:51:37.203: E/AndroidRuntime(276): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
04-16 13:51:37.203: E/AndroidRuntime(276): ... 11 more
04-16 13:51:37.203: E/AndroidRuntime(276): Caused by: java.lang.reflect.InvocationTargetException
04-16 13:51:37.203: E/AndroidRuntime(276): at android.widget.ImageView.<init>(ImageView.java:108)
04-16 13:51:37.203: E/AndroidRuntime(276): at java.lang.reflect.Constructor.constructNative(Native Method)
04-16 13:51:37.203: E/AndroidRuntime(276): at java.lang.reflect.Constructor.newInstance(Constructor.java:446)
04-16 13:51:37.203: E/AndroidRuntime(276): at android.view.LayoutInflater.createView(LayoutInflater.java:500)
04-16 13:51:37.203: E/AndroidRuntime(276): ... 22 more
04-16 13:51:37.203: E/AndroidRuntime(276): Caused by: java.lang.OutOfMemoryError: bitmap size exceeds VM budget
04-16 13:51:37.203: E/AndroidRuntime(276): at android.graphics.Bitmap.nativeCreate(Native Method)
04-16 13:51:37.203: E/AndroidRuntime(276): at android.graphics.Bitmap.createBitmap(Bitmap.java:468)
04-16 13:51:37.203: E/AndroidRuntime(276): at android.graphics.Bitmap.createBitmap(Bitmap.java:435)
04-16 13:51:37.203: E/AndroidRuntime(276): at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:340)
04-16 13:51:37.203: E/AndroidRuntime(276): at android.graphics.BitmapFactory.finishDecode(BitmapFactory.java:488)
04-16 13:51:37.203: E/AndroidRuntime(276): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:462)
04-16 13:51:37.203: E/AndroidRuntime(276): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:323)
04-16 13:51:37.203: E/AndroidRuntime(276): at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:697)
04-16 13:51:37.203: E/AndroidRuntime(276): at android.content.res.Resources.loadDrawable(Resources.java:1709)
04-16 13:51:37.203: E/AndroidRuntime(276): at android.content.res.Resources.getDrawable(Resources.java:581)
04-16 13:51:37.203: E/AndroidRuntime(276): at android.graphics.drawable.AnimationDrawable.inflate(AnimationDrawable.java:265)
04-16 13:51:37.203: E/AndroidRuntime(276): at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:788)
04-16 13:51:37.203: E/AndroidRuntime(276): at android.graphics.drawable.Drawable.createFromXml(Drawable.java:729)
04-16 13:51:37.203: E/AndroidRuntime(276): at android.content.res.Resources.loadDrawable(Resources.java:1694)
04-16 13:51:37.203: E/AndroidRuntime(276): at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
04-16 13:51:37.203: E/AndroidRuntime(276): at android.view.View.<init>(View.java:1885)
04-16 13:51:37.203: E/AndroidRuntime(276): at android.widget.ImageView.<init>(ImageView.java:112)
Any help is much appreciated, I just cannot figure out what is causing the problem.
Thanks
The images you are using might be too large for an animation. How large are they? In an animation, Android loads all of the images into memory and uncompresses them meaning that every pixel will take 4 bytes. So 50k would mean that your image is 111px x 111px. It seems from the error each frame is about 480 x 640, which is really large. Try using smaller images.
Im designing my first android application and keep coming up with the following error which is draining the life out of me and I do not understand it very well (Please find my Logcat (verbose), Java Code(this i played around with and this began to occur once started to work on my editButton and buttonUpdate bit. Does it have anything to do with the editStatus? I really think it may) and I have also put in my manifest file:
LOGCAT verbose
04-21 15:30:23.388: D/AndroidRuntime(276): Shutting down VM
04-21 15:30:23.388: W/dalvikvm(276): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
04-21 15:30:23.427: E/AndroidRuntime(276): FATAL EXCEPTION: main
04-21 15:30:23.427: E/AndroidRuntime(276): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.locator.demo/com.locator.demo.LocatorDemoActivity}: java.lang.ClassCastException: android.widget.TextView
04-21 15:30:23.427: E/AndroidRuntime(276): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
04-21 15:30:23.427: E/AndroidRuntime(276): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
04-21 15:30:23.427: E/AndroidRuntime(276): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
04-21 15:30:23.427: E/AndroidRuntime(276): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
04-21 15:30:23.427: E/AndroidRuntime(276): at android.os.Handler.dispatchMessage(Handler.java:99)
04-21 15:30:23.427: E/AndroidRuntime(276): at android.os.Looper.loop(Looper.java:123)
04-21 15:30:23.427: E/AndroidRuntime(276): at android.app.ActivityThread.main(ActivityThread.java:4627)
04-21 15:30:23.427: E/AndroidRuntime(276): at java.lang.reflect.Method.invokeNative(Native Method)
04-21 15:30:23.427: E/AndroidRuntime(276): at java.lang.reflect.Method.invoke(Method.java:521)
04-21 15:30:23.427: E/AndroidRuntime(276): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
04-21 15:30:23.427: E/AndroidRuntime(276): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
04-21 15:30:23.427: E/AndroidRuntime(276): at dalvik.system.NativeStart.main(Native Method)
04-21 15:30:23.427: E/AndroidRuntime(276): Caused by: java.lang.ClassCastException: android.widget.TextView
04-21 15:30:23.427: E/AndroidRuntime(276): at com.locator.demo.LocatorDemoActivity.onCreate(LocatorDemoActivity.java:21)
04-21 15:30:23.427: E/AndroidRuntime(276): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
04-21 15:30:23.427: E/AndroidRuntime(276): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
04-21 15:30:23.427: E/AndroidRuntime(276): ... 11 more
04-21 15:35:23.607: I/Process(276): Sending signal. PID: 276 SIG: 9
04-21 15:50:32.127: D/AndroidRuntime(301): Shutting down VM
04-21 15:50:32.127: W/dalvikvm(301): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
04-21 15:50:32.147: E/AndroidRuntime(301): FATAL EXCEPTION: main
04-21 15:50:32.147: E/AndroidRuntime(301): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.locator.demo/com.locator.demo.LocatorDemoActivity}: java.lang.ClassCastException: android.widget.TextView
04-21 15:50:32.147: E/AndroidRuntime(301): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
04-21 15:50:32.147: E/AndroidRuntime(301): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
04-21 15:50:32.147: E/AndroidRuntime(301): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
04-21 15:50:32.147: E/AndroidRuntime(301): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
04-21 15:50:32.147: E/AndroidRuntime(301): at android.os.Handler.dispatchMessage(Handler.java:99)
04-21 15:50:32.147: E/AndroidRuntime(301): at android.os.Looper.loop(Looper.java:123)
04-21 15:50:32.147: E/AndroidRuntime(301): at android.app.ActivityThread.main(ActivityThread.java:4627)
04-21 15:50:32.147: E/AndroidRuntime(301): at java.lang.reflect.Method.invokeNative(Native Method)
04-21 15:50:32.147: E/AndroidRuntime(301): at java.lang.reflect.Method.invoke(Method.java:521)
04-21 15:50:32.147: E/AndroidRuntime(301): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
04-21 15:50:32.147: E/AndroidRuntime(301): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
04-21 15:50:32.147: E/AndroidRuntime(301): at dalvik.system.NativeStart.main(Native Method)
04-21 15:50:32.147: E/AndroidRuntime(301): Caused by: java.lang.ClassCastException: android.widget.TextView
04-21 15:50:32.147: E/AndroidRuntime(301): at com.locator.demo.LocatorDemoActivity.onCreate(LocatorDemoActivity.java:21)
04-21 15:50:32.147: E/AndroidRuntime(301): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
04-21 15:50:32.147: E/AndroidRuntime(301): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
04-21 15:50:32.147: E/AndroidRuntime(301): ... 11 more
CODE:
package com.locator.demo;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
public class LocatorDemoActivity extends Activity implements OnClickListener {
EditText editStatus;
Button buttonUpdate;
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.locationstatus);
editStatus = (EditText)findViewById(R.id.edit_status);
buttonUpdate = (Button)findViewById(R.id.button_update);
buttonUpdate.setOnClickListener(this);
//have button 'listen' for click
}
public void onClick(View arg0) {
// TODO Auto-generated method stub
}
}
ANDROID Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.locator.demo"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="8" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_main" >
<activity
android:name=".LocatorDemoActivity"
android:label="#string/app_main" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
I have;
attempted to do adb kill-server and adb start-server and run it with an without an emulator as suggested in another post. Please be slightly understanding as my knowledge of eclipse and Java is pretty low and im learning.
Please help
As seen from this error:
java.lang.RuntimeException: Unable to start activity
ComponentInfo{com.locator.demo/com.locator.demo.LocatorDemoActivity}:
java.lang.ClassCastException: android.widget.TextView
And this one:
Caused by: java.lang.ClassCastException: android.widget.TextView
You are trying to cast a TextView to EditText ( in this line: editStatus = (EditText)findViewById(R.id.edit_status);).
Go to locationstatus.xml, and change the TextView with the id edit_status to EditText.
When I run my android application it gives an error "The application has stopped working,please try again". Please help me to solve this problem. i have created a method which gets called when the button gets clicked. When I include the code for calling another class in this method it shows the above error & when I remove that code it neither shows the error nor goes ahead when listview etc. gets clicked. Can you please check my code and help me please.
CODE:
public void myClickHandler(View view)
{
//Toast.makeText(this, "yesss",Toast.LENGTH_LONG).show();
setContentView(R.layout.screen1);
ListAdapter adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, city);
ListView FirstProjectActivity = (ListView) findViewById(R.id.mylist1);
FirstProjectActivity.setAdapter(adapter);
Intent myIntent = new Intent(FirstProjectActivity.this,
City.class);
FirstProjectActivity.this.startActivity(myIntent);
//startActivity(new Intent(FirstProjectActivity.this, City.class));
}
LOGCAT is as follows:
03-02 18:56:28.136: D/AndroidRuntime(316): Shutting down VM
03-02 18:56:28.136: W/dalvikvm(316): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
03-02 18:56:28.226: E/AndroidRuntime(316): FATAL EXCEPTION: main
03-02 18:56:28.226: E/AndroidRuntime(316): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.FirstProject/com.example.FirstProject.FirstProjectActivity}: java.lang.NullPointerException
03-02 18:56:28.226: E/AndroidRuntime(316): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
03-02 18:56:28.226: E/AndroidRuntime(316): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
03-02 18:56:28.226: E/AndroidRuntime(316): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
03-02 18:56:28.226: E/AndroidRuntime(316): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
03-02 18:56:28.226: E/AndroidRuntime(316): at android.os.Handler.dispatchMessage(Handler.java:99)
03-02 18:56:28.226: E/AndroidRuntime(316): at android.os.Looper.loop(Looper.java:123)
03-02 18:56:28.226: E/AndroidRuntime(316): at android.app.ActivityThread.main(ActivityThread.java:4627)
03-02 18:56:28.226: E/AndroidRuntime(316): at java.lang.reflect.Method.invokeNative(Native Method)
03-02 18:56:28.226: E/AndroidRuntime(316): at java.lang.reflect.Method.invoke(Method.java:521)
03-02 18:56:28.226: E/AndroidRuntime(316): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
03-02 18:56:28.226: E/AndroidRuntime(316): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
03-02 18:56:28.226: E/AndroidRuntime(316): at dalvik.system.NativeStart.main(Native Method)
03-02 18:56:28.226: E/AndroidRuntime(316): Caused by: java.lang.NullPointerException
03-02 18:56:28.226: E/AndroidRuntime(316): at com.example.FirstProject.FirstProjectActivity.onCreate(FirstProjectActivity.java:37)
03-02 18:56:28.226: E/AndroidRuntime(316): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
03-02 18:56:28.226: E/AndroidRuntime(316): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
03-02 18:56:28.226: E/AndroidRuntime(316): ... 11 more
03-02 18:56:35.396: I/Process(316): Sending signal. PID: 316 SIG: 9
03-02 19:02:51.836: D/AndroidRuntime(351): Shutting down VM
03-02 19:02:51.836: W/dalvikvm(351): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
03-02 19:02:51.866: E/AndroidRuntime(351): FATAL EXCEPTION: main
03-02 19:02:51.866: E/AndroidRuntime(351): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.FirstProject/com.example.FirstProject.FirstProjectActivity}: java.lang.NullPointerException
03-02 19:02:51.866: E/AndroidRuntime(351): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
03-02 19:02:51.866: E/AndroidRuntime(351): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
03-02 19:02:51.866: E/AndroidRuntime(351): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
03-02 19:02:51.866: E/AndroidRuntime(351): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
03-02 19:02:51.866: E/AndroidRuntime(351): at android.os.Handler.dispatchMessage(Handler.java:99)
03-02 19:02:51.866: E/AndroidRuntime(351): at android.os.Looper.loop(Looper.java:123)
03-02 19:02:51.866: E/AndroidRuntime(351): at android.app.ActivityThread.main(ActivityThread.java:4627)
03-02 19:02:51.866: E/AndroidRuntime(351): at java.lang.reflect.Method.invokeNative(Native Method)
03-02 19:02:51.866: E/AndroidRuntime(351): at java.lang.reflect.Method.invoke(Method.java:521)
03-02 19:02:51.866: E/AndroidRuntime(351): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
03-02 19:02:51.866: E/AndroidRuntime(351): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
03-02 19:02:51.866: E/AndroidRuntime(351): at dalvik.system.NativeStart.main(Native Method)
03-02 19:02:51.866: E/AndroidRuntime(351): Caused by: java.lang.NullPointerException
03-02 19:02:51.866: E/AndroidRuntime(351): at com.example.FirstProject.FirstProjectActivity.onCreate(FirstProjectActivity.java:37)
03-02 19:02:51.866: E/AndroidRuntime(351): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
03-02 19:02:51.866: E/AndroidRuntime(351): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
03-02 19:02:51.866: E/AndroidRuntime(351): ... 11 more
03-02 19:03:03.647: I/Process(351): Sending signal. PID: 351 SIG: 9
03-02 20:11:17.722: W/KeyCharacterMap(379): No keyboard for id 0
03-02 20:11:17.926: W/KeyCharacterMap(379): Using default keymap: /system/usr/keychars/qwerty.kcm.bin
03-02 20:11:28.441: D/dalvikvm(379): GC_EXPLICIT freed 3121 objects / 172672 bytes in 1696ms
03-03 01:03:02.696: W/KeyCharacterMap(406): No keyboard for id 0
03-03 01:03:02.696: W/KeyCharacterMap(406): Using default keymap: /system/usr/keychars/qwerty.kcm.bin
03-03 01:03:08.566: D/dalvikvm(406): GC_EXPLICIT freed 2874 objects / 162408 bytes in 192ms
03-03 01:33:06.566: D/AndroidRuntime(432): Shutting down VM
03-03 01:33:06.566: W/dalvikvm(432): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
03-03 01:33:06.726: E/AndroidRuntime(432): FATAL EXCEPTION: main
03-03 01:33:06.726: E/AndroidRuntime(432): java.lang.IllegalStateException: Could not execute method of the activity
03-03 01:33:06.726: E/AndroidRuntime(432): at android.view.View$1.onClick(View.java:2072)
03-03 01:33:06.726: E/AndroidRuntime(432): at android.view.View.performClick(View.java:2408)
03-03 01:33:06.726: E/AndroidRuntime(432): at android.view.View$PerformClick.run(View.java:8816)
03-03 01:33:06.726: E/AndroidRuntime(432): at android.os.Handler.handleCallback(Handler.java:587)
03-03 01:33:06.726: E/AndroidRuntime(432): at android.os.Handler.dispatchMessage(Handler.java:92)
03-03 01:33:06.726: E/AndroidRuntime(432): at android.os.Looper.loop(Looper.java:123)
03-03 01:33:06.726: E/AndroidRuntime(432): at android.app.ActivityThread.main(ActivityThread.java:4627)
03-03 01:33:06.726: E/AndroidRuntime(432): at java.lang.reflect.Method.invokeNative(Native Method)
03-03 01:33:06.726: E/AndroidRuntime(432): at java.lang.reflect.Method.invoke(Method.java:521)
03-03 01:33:06.726: E/AndroidRuntime(432): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
03-03 01:33:06.726: E/AndroidRuntime(432): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
03-03 01:33:06.726: E/AndroidRuntime(432): at dalvik.system.NativeStart.main(Native Method)
03-03 01:33:06.726: E/AndroidRuntime(432): Caused by: java.lang.reflect.InvocationTargetException
03-03 01:33:06.726: E/AndroidRuntime(432): at com.example.FirstProject.FirstProjectActivity.myClickHandler(FirstProjectActivity.java:69)
03-03 01:33:06.726: E/AndroidRuntime(432): at java.lang.reflect.Method.invokeNative(Native Method)
03-03 01:33:06.726: E/AndroidRuntime(432): at java.lang.reflect.Method.invoke(Method.java:521)
03-03 01:33:06.726: E/AndroidRuntime(432): at android.view.View$1.onClick(View.java:2067)
03-03 01:33:06.726: E/AndroidRuntime(432): ... 11 more
03-03 01:33:06.726: E/AndroidRuntime(432): Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.FirstProject/com.example.FirstProject.City}; have you declared this activity in your AndroidManifest.xml?
03-03 01:33:06.726: E/AndroidRuntime(432): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1404)
03-03 01:33:06.726: E/AndroidRuntime(432): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1378)
03-03 01:33:06.726: E/AndroidRuntime(432): at android.app.Activity.startActivityForResult(Activity.java:2817)
03-03 01:33:06.726: E/AndroidRuntime(432): at android.app.Activity.startActivity(Activity.java:2923)
03-03 01:33:06.726: E/AndroidRuntime(432): ... 15 more
03-03 01:33:08.956: I/Process(432): Sending signal. PID: 432 SIG: 9
03-03 01:34:05.387: D/AndroidRuntime(460): Shutting down VM
03-03 01:34:05.387: W/dalvikvm(460): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
03-03 01:34:05.417: E/AndroidRuntime(460): FATAL EXCEPTION: main
03-03 01:34:05.417: E/AndroidRuntime(460): java.lang.IllegalStateException: Could not execute method of the activity
03-03 01:34:05.417: E/AndroidRuntime(460): at android.view.View$1.onClick(View.java:2072)
03-03 01:34:05.417: E/AndroidRuntime(460): at android.view.View.performClick(View.java:2408)
03-03 01:34:05.417: E/AndroidRuntime(460): at android.view.View$PerformClick.run(View.java:8816)
03-03 01:34:05.417: E/AndroidRuntime(460): at android.os.Handler.handleCallback(Handler.java:587)
03-03 01:34:05.417: E/AndroidRuntime(460): at android.os.Handler.dispatchMessage(Handler.java:92)
03-03 01:34:05.417: E/AndroidRuntime(460): at android.os.Looper.loop(Looper.java:123)
03-03 01:34:05.417: E/AndroidRuntime(460): at android.app.ActivityThread.main(ActivityThread.java:4627)
03-03 01:34:05.417: E/AndroidRuntime(460): at java.lang.reflect.Method.invokeNative(Native Method)
03-03 01:34:05.417: E/AndroidRuntime(460): at java.lang.reflect.Method.invoke(Method.java:521)
03-03 01:34:05.417: E/AndroidRuntime(460): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
03-03 01:34:05.417: E/AndroidRuntime(460): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
03-03 01:34:05.417: E/AndroidRuntime(460): at dalvik.system.NativeStart.main(Native Method)
03-03 01:34:05.417: E/AndroidRuntime(460): Caused by: java.lang.reflect.InvocationTargetException
03-03 01:34:05.417: E/AndroidRuntime(460): at com.example.FirstProject.FirstProjectActivity.myClickHandler(FirstProjectActivity.java:70)
03-03 01:34:05.417: E/AndroidRuntime(460): at java.lang.reflect.Method.invokeNative(Native Method)
03-03 01:34:05.417: E/AndroidRuntime(460): at java.lang.reflect.Method.invoke(Method.java:521)
03-03 01:34:05.417: E/AndroidRuntime(460): at android.view.View$1.onClick(View.java:2067)
03-03 01:34:05.417: E/AndroidRuntime(460): ... 11 more
03-03 01:34:05.417: E/AndroidRuntime(460): Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.FirstProject/com.example.FirstProject.City}; have you declared this activity in your AndroidManifest.xml?
03-03 01:34:05.417: E/AndroidRuntime(460): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1404)
03-03 01:34:05.417: E/AndroidRuntime(460): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1378)
03-03 01:34:05.417: E/AndroidRuntime(460): at android.app.Activity.startActivityForResult(Activity.java:2817)
03-03 01:34:05.417: E/AndroidRuntime(460): at android.app.Activity.startActivity(Activity.java:2923)
03-03 01:34:05.417: E/AndroidRuntime(460): ... 15 more
03-03 01:34:11.016: I/Process(460): Sending signal. PID: 460 SIG: 9
03-03 01:35:33.547: D/AndroidRuntime(490): Shutting down VM
03-03 01:35:33.557: W/dalvikvm(490): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
03-03 01:35:33.577: E/AndroidRuntime(490): FATAL EXCEPTION: main
03-03 01:35:33.577: E/AndroidRuntime(490): java.lang.IllegalStateException: Could not execute method of the activity
03-03 01:35:33.577: E/AndroidRuntime(490): at android.view.View$1.onClick(View.java:2072)
03-03 01:35:33.577: E/AndroidRuntime(490): at android.view.View.performClick(View.java:2408)
03-03 01:35:33.577: E/AndroidRuntime(490): at android.view.View$PerformClick.run(View.java:8816)
03-03 01:35:33.577: E/AndroidRuntime(490): at android.os.Handler.handleCallback(Handler.java:587)
03-03 01:35:33.577: E/AndroidRuntime(490): at android.os.Handler.dispatchMessage(Handler.java:92)
03-03 01:35:33.577: E/AndroidRuntime(490): at android.os.Looper.loop(Looper.java:123)
03-03 01:35:33.577: E/AndroidRuntime(490): at android.app.ActivityThread.main(ActivityThread.java:4627)
03-03 01:35:33.577: E/AndroidRuntime(490): at java.lang.reflect.Method.invokeNative(Native Method)
03-03 01:35:33.577: E/AndroidRuntime(490): at java.lang.reflect.Method.invoke(Method.java:521)
03-03 01:35:33.577: E/AndroidRuntime(490): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
03-03 01:35:33.577: E/AndroidRuntime(490): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
03-03 01:35:33.577: E/AndroidRuntime(490): at dalvik.system.NativeStart.main(Native Method)
03-03 01:35:33.577: E/AndroidRuntime(490): Caused by: java.lang.reflect.InvocationTargetException
03-03 01:35:33.577: E/AndroidRuntime(490): at com.example.FirstProject.FirstProjectActivity.myClickHandler(FirstProjectActivity.java:70)
03-03 01:35:33.577: E/AndroidRuntime(490): at java.lang.reflect.Method.invokeNative(Native Method)
03-03 01:35:33.577: E/AndroidRuntime(490): at java.lang.reflect.Method.invoke(Method.java:521)
03-03 01:35:33.577: E/AndroidRuntime(490): at android.view.View$1.onClick(View.java:2067)
03-03 01:35:33.577: E/AndroidRuntime(490): ... 11 more
03-03 01:35:33.577: E/AndroidRuntime(490): Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.FirstProject/com.example.FirstProject.City}; have you declared this activity in your AndroidManifest.xml?
03-03 01:35:33.577: E/AndroidRuntime(490): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1404)
03-03 01:35:33.577: E/AndroidRuntime(490): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1378)
03-03 01:35:33.577: E/AndroidRuntime(490): at android.app.Activity.startActivityForResult(Activity.java:2817)
03-03 01:35:33.577: E/AndroidRuntime(490): at android.app.Activity.startActivity(Activity.java:2923)
03-03 01:35:33.577: E/AndroidRuntime(490): ... 15 more
03-03 01:35:39.176: I/Process(490): Sending signal. PID: 490 SIG: 9
03-03 01:36:06.947: D/AndroidRuntime(517): Shutting down VM
03-03 01:36:06.947: W/dalvikvm(517): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
03-03 01:36:06.967: E/AndroidRuntime(517): FATAL EXCEPTION: main
03-03 01:36:06.967: E/AndroidRuntime(517): java.lang.IllegalStateException: Could not execute method of the activity
03-03 01:36:06.967: E/AndroidRuntime(517): at android.view.View$1.onClick(View.java:2072)
03-03 01:36:06.967: E/AndroidRuntime(517): at android.view.View.performClick(View.java:2408)
03-03 01:36:06.967: E/AndroidRuntime(517): at android.view.View$PerformClick.run(View.java:8816)
03-03 01:36:06.967: E/AndroidRuntime(517): at android.os.Handler.handleCallback(Handler.java:587)
03-03 01:36:06.967: E/AndroidRuntime(517): at android.os.Handler.dispatchMessage(Handler.java:92)
03-03 01:36:06.967: E/AndroidRuntime(517): at android.os.Looper.loop(Looper.java:123)
03-03 01:36:06.967: E/AndroidRuntime(517): at android.app.ActivityThread.main(ActivityThread.java:4627)
03-03 01:36:06.967: E/AndroidRuntime(517): at java.lang.reflect.Method.invokeNative(Native Method)
03-03 01:36:06.967: E/AndroidRuntime(517): at java.lang.reflect.Method.invoke(Method.java:521)
03-03 01:36:06.967: E/AndroidRuntime(517): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
03-03 01:36:06.967: E/AndroidRuntime(517): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
03-03 01:36:06.967: E/AndroidRuntime(517): at dalvik.system.NativeStart.main(Native Method)
03-03 01:36:06.967: E/AndroidRuntime(517): Caused by: java.lang.reflect.InvocationTargetException
03-03 01:36:06.967: E/AndroidRuntime(517): at com.example.FirstProject.FirstProjectActivity.myClickHandler(FirstProjectActivity.java:70)
03-03 01:36:06.967: E/AndroidRuntime(517): at java.lang.reflect.Method.invokeNative(Native Method)
03-03 01:36:06.967: E/AndroidRuntime(517): at java.lang.reflect.Method.invoke(Method.java:521)
03-03 01:36:06.967: E/AndroidRuntime(517): at android.view.View$1.onClick(View.java:2067)
03-03 01:36:06.967: E/AndroidRuntime(517): ... 11 more
03-03 01:36:06.967: E/AndroidRuntime(517): Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.FirstProject/com.example.FirstProject.City}; have you declared this activity in your AndroidManifest.xml?
03-03 01:36:06.967: E/AndroidRuntime(517): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1404)
03-03 01:36:06.967: E/AndroidRuntime(517): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1378)
03-03 01:36:06.967: E/AndroidRuntime(517): at android.app.Activity.startActivityForResult(Activity.java:2817)
03-03 01:36:06.967: E/AndroidRuntime(517): at android.app.Activity.startActivity(Activity.java:2923)
03-03 01:36:06.967: E/AndroidRuntime(517): ... 15 more
03-03 01:36:13.306: I/Process(517): Sending signal. PID: 517 SIG: 9
When you want to detect if you click on an item you need to implement the onItemClickedListener i will give you an example below like i would do it:
listView.setOnItemClickListener(new MyOnitemClickListener());
//no i make my own class that impelemnts the onitemclicklistener
public class MyOnitemClickListener implements OnItemClickListener {
private int position = 0;
public void onItemClick(AdapterView<?> parent, View view, int pos,
long lat) {
// clicked on parent.getid()
if (parent.getId() == R.id.listView) {
//do something
}
}
}
after a crash, try looking for the first couple of red lines the LOGCAT spews to you as they usually explain what happened.
the following line :
java.lang.NullPointerException
(in line 5) showed up on you log, it usually means your trying to use an uninitialized object.
refer to:
What is a NullPointerException, and how do I fix it?
I am getting this error in my application, and this happens only on UPC300-2.2 Viewsonic G-Tablet. All answers I've found so far (including this one) adviced on putting
<uses-permission android:name="android.permission.INTERNET"/>
to the manifest file, but it doesn't help.
Here is the complete stacktrace:
java.lang.NoClassDefFoundError: android.net.NetworkConnectivityListener
at
com.google.android.maps.MapActivity.onCreate(MapActivity.java:199)
at
myapp.Activity.ActivityMapSearch.onCreate(ActivityMapSearch.java:99)
at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
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:868)
at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
at
dalvik.system.NativeStart.main(Native
Method)
If that is TRUE, you can grab the source code of the class from the Android Source and add it yourself