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.
Related
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
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.
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.
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
This is my logcat and the problem is that the application is force closing and i want to knw the line or method which is causing this. I m new to android so cant understand a word of logcat. Thanks in advance
01-16 17:32:56.584: D/dalvikvm(276): GC freed 596 objects / 49984 bytes in 101ms
01-16 17:33:09.233: D/AndroidRuntime(276): Shutting down VM
01-16 17:33:09.233: W/dalvikvm(276): threadid=3: thread exiting with uncaught exception (group=0x4001b188)
01-16 17:33:09.233: E/AndroidRuntime(276): Uncaught handler: thread main exiting due to uncaught exception
01-16 17:33:09.273: E/AndroidRuntime(276): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.ymappuser/com.ymappuser.Manualloc}: java.lang.RuntimeException: java.lang.NullPointerException
01-16 17:33:09.273: E/AndroidRuntime(276): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2496)
01-16 17:33:09.273: E/AndroidRuntime(276): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
01-16 17:33:09.273: E/AndroidRuntime(276): at android.app.ActivityThread.access$2200(ActivityThread.java:119)
01-16 17:33:09.273: E/AndroidRuntime(276): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
01-16 17:33:09.273: E/AndroidRuntime(276): at android.os.Handler.dispatchMessage(Handler.java:99)
01-16 17:33:09.273: E/AndroidRuntime(276): at android.os.Looper.loop(Looper.java:123)
01-16 17:33:09.273: E/AndroidRuntime(276): at android.app.ActivityThread.main(ActivityThread.java:4363)
01-16 17:33:09.273: E/AndroidRuntime(276): at java.lang.reflect.Method.invokeNative(Native Method)
01-16 17:33:09.273: E/AndroidRuntime(276): at java.lang.reflect.Method.invoke(Method.java:521)
01-16 17:33:09.273: E/AndroidRuntime(276): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
01-16 17:33:09.273: E/AndroidRuntime(276): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
01-16 17:33:09.273: E/AndroidRuntime(276): at dalvik.system.NativeStart.main(Native Method)
01-16 17:33:09.273: E/AndroidRuntime(276): Caused by: java.lang.RuntimeException: java.lang.NullPointerException
01-16 17:33:09.273: E/AndroidRuntime(276): at com.ymappuser.Manualloc.getCountries(Manualloc.java:270)
01-16 17:33:09.273: E/AndroidRuntime(276): at com.ymappuser.Manualloc.fillcountry(Manualloc.java:83)
01-16 17:33:09.273: E/AndroidRuntime(276): at com.ymappuser.Manualloc.onCreate(Manualloc.java:75)
01-16 17:33:09.273: E/AndroidRuntime(276): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
01-16 17:33:09.273: E/AndroidRuntime(276): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459)
01-16 17:33:09.273: E/AndroidRuntime(276): ... 11 more
01-16 17:33:09.273: E/AndroidRuntime(276): Caused by: java.lang.NullPointerException
01-16 17:33:09.273: E/AndroidRuntime(276): at com.ymappuser.Manualloc.getCountries(Manualloc.java:243)
01-16 17:33:09.273: E/AndroidRuntime(276): ... 15 more
01-16 17:33:09.384: I/dalvikvm(276): threadid=7: reacting to signal 3
01-16 17:33:09.404: I/dalvikvm(276): Wrote stack trace to '/data/anr/traces.txt'
01-16 17:33:11.353: I/Process(276): Sending signal. PID: 276 SIG: 9
01-16 17:33:13.004: D/dalvikvm(284): GC freed 623 objects / 51024 bytes in 125ms
01-16 17:34:21.646: D/dalvikvm(284): GC freed 288 objects / 14672 bytes in 987ms
you are getting null pointer exception in method getCountries, in class Manualloc at line 270, you can check there by debugging what object on the line is null, and work accordingly.