StackOverflow exception in Fragments - android

I have a tabhost with 5 tabs which are FragmentActivity. One of them contains a sequence of 7 views. I think that each is a fragment, but when I get to fragment 7 the app explodes.
When I press the continue button in each fragment I start a new fragment in this way:
MyFragment newFragment = new MyFragment ();
FragmentTransaction transaction = getFragmentManager().beginTransaction();
transaction.replace(R.id.publish_map_direction, newFragment);
transaction.addToBackStack(null);
transaction.commit();
This is the error:
11-14 13:50:33.640: I/dalvikvm(13823): threadid=1: stack overflow on call to Landroid/text/Layout;.draw:VLLLI
11-14 13:50:33.640: I/dalvikvm(13823): method requires 288+20+60=368 bytes, fp is 0x4428a42c (300 left)
11-14 13:50:33.640: I/dalvikvm(13823): expanding stack end (0x4428a300 to 0x4428a000)
11-14 13:50:33.640: I/dalvikvm(13823): Shrank stack (to 0x4428a300, curFrame is 0x4428cc74)
11-14 13:50:33.640: D/AndroidRuntime(13823): Shutting down VM
11-14 13:50:33.640: W/dalvikvm(13823): threadid=1: thread exiting with uncaught exception (group=0x40015578)
11-14 13:50:33.703: E/AndroidRuntime(13823): FATAL EXCEPTION: main
11-14 13:50:33.703: E/AndroidRuntime(13823): java.lang.StackOverflowError
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.widget.TextView.onDraw(TextView.java:4229)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.View.draw(View.java:6933)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.View.draw(View.java:6936)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.View.draw(View.java:6936)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.View.buildDrawingCache(View.java:6695)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.ViewGroup.onAnimationStart(ViewGroup.java:1259)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.ViewGroup.drawChild(ViewGroup.java:1505)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.View.draw(View.java:6936)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.View.draw(View.java:6936)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.View.draw(View.java:6936)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.View.draw(View.java:6936)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.View.draw(View.java:6936)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.View.draw(View.java:6936)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.widget.FrameLayout.draw(FrameLayout.java:357)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.View.draw(View.java:6936)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.View.draw(View.java:6936)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.widget.FrameLayout.draw(FrameLayout.java:357)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.View.draw(View.java:6936)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.widget.FrameLayout.draw(FrameLayout.java:357)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.View.draw(View.java:6936)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.widget.FrameLayout.draw(FrameLayout.java:357)
11-14 13:50:33.703: E/AndroidRuntime(13823): at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:1904)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.ViewRoot.draw(ViewRoot.java:1527)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.ViewRoot.performTraversals(ViewRoot.java:1263)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.ViewRoot.handleMessage(ViewRoot.java:1865)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.os.Handler.dispatchMessage(Handler.java:99)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.os.Looper.loop(Looper.java:130)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.app.ActivityThread.main(ActivityThread.java:3687)
11-14 13:50:33.703: E/AndroidRuntime(13823): at java.lang.reflect.Method.invokeNative(Native Method)
11-14 13:50:33.703: E/AndroidRuntime(13823): at java.lang.reflect.Method.invoke(Method.java:507)
11-14 13:50:33.703: E/AndroidRuntime(13823): at com.
Should I structure my app in a different way?

Yes.
I would recommend using just fragments, instead of nesting fragment activities inside the tab host. I usually create a tab bar and just have a frame layout below it that I put a fragment in. then i replace fragments depending on what gets clicked. That should definitely help, because I think you just have too many things going at the same time.

Related

Listview crashes on scrolling in a fragment under tabhost activity

My application has two tabhosts and both of them are necessary. I had to use tabhost instead of actionbar as my application need to be supported by the low-end android device.
Now, my FragmentActivity has two fragments and one of them has a ListView. The ListView loads fine but the application crashes with java.lang.StackOverflowError when I begin to scroll the list.
My layout for each row is very simple and as i told before it loads first time perfectly and crashes while its scrolled.
I put my logcat here.
12-02 15:14:26.929: E/AndroidRuntime(22971): FATAL EXCEPTION: GUI Thread
12-02 15:14:26.929: E/AndroidRuntime(22971): java.lang.StackOverflowError
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.graphics.Paint.measureText(Paint.java:1020)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.graphics.Paint.measureText(Paint.java:1057)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.text.Styled.drawDirectionalRun(Styled.java:284)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.text.Styled.measureText(Styled.java:447)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.text.Layout.measureText(Layout.java:1888)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.text.Layout.getLineMax(Layout.java:841)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.text.Layout.draw(Layout.java:386)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.text.BoringLayout.draw(BoringLayout.java:365)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.widget.TextView.onDraw(TextView.java:4334)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.View.draw(View.java:6880)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.View.draw(View.java:6883)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.View.buildDrawingCache(View.java:6642)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.View.getDrawingCache(View.java:6428)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.drawChild(ViewGroup.java:1571)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.widget.AbsListView.dispatchDraw(AbsListView.java:1643)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.widget.ListView.dispatchDraw(ListView.java:3207)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.View.draw(View.java:6986)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.widget.AbsListView.draw(AbsListView.java:3021)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.View.draw(View.java:6883)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.View.draw(View.java:6883)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.support.v4.view.ViewPager.draw(ViewPager.java:2153)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.View.draw(View.java:6883)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.View.draw(View.java:6883)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.widget.FrameLayout.draw(FrameLayout.java:357)
12-02 15:14:26.929: E/AndroidRuntime(22971): at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:1964)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewRoot.draw(ViewRoot.java:1529)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewRoot.performTra

Could not find appcompat_v7.apk and android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1880)

i have problem. when run and i debug program i have
[2014-11-14 03:57:23 - Traffic] Android Launch!
[2014-11-14 03:57:23 - Traffic] adb is running normally.
[2014-11-14 03:57:23 - Traffic] Performing com.fuad.traffic.MainActivity activity launch
[2014-11-14 03:57:26 - Traffic] Uploading Traffic.apk onto device 'YT910DUTNU'
[2014-11-14 03:57:26 - Traffic] Installing Traffic.apk...
[2014-11-14 03:57:33 - Traffic] Success!
[2014-11-14 03:57:33 - appcompat_v7] Could not find appcompat_v7.apk!
[2014-11-14 03:57:33 - Traffic] Starting activity com.fuad.traffic.MainActivity on device YT910DUTNU
that is my problem, and when i running in phone this i have problem again like this my problem
11-14 19:10:02.090: W/dalvikvm(28725): Unable to resolve superclass of Lcom/fuad/traffic/MainActivity; (83)
11-14 19:10:02.090: W/dalvikvm(28725): Link of class 'Lcom/fuad/traffic/MainActivity;' failed
11-14 19:10:02.090: W/dalvikvm(28725): threadid=1: thread exiting with uncaught exception (group=0x40b019f0)
11-14 19:10:02.100: E/AndroidRuntime(28725): FATAL EXCEPTION: main
11-14 19:10:02.100: E/AndroidRuntime(28725): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.fuad.traffic/com.fuad.traffic.MainActivity}: java.lang.ClassNotFoundException: com.fuad.traffic.MainActivity
11-14 19:10:02.100: E/AndroidRuntime(28725): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1880)
11-14 19:10:02.100: E/AndroidRuntime(28725): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
11-14 19:10:02.100: E/AndroidRuntime(28725): at android.app.ActivityThread.access$600(ActivityThread.java:123)
11-14 19:10:02.100: E/AndroidRuntime(28725): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
11-14 19:10:02.100: E/AndroidRuntime(28725): at android.os.Handler.dispatchMessage(Handler.java:99)
11-14 19:10:02.100: E/AndroidRuntime(28725): at android.os.Looper.loop(Looper.java:137)
11-14 19:10:02.100: E/AndroidRuntime(28725): at android.app.ActivityThread.main(ActivityThread.java:4424)
11-14 19:10:02.100: E/AndroidRuntime(28725): at java.lang.reflect.Method.invokeNative(Native Method)
11-14 19:10:02.100: E/AndroidRuntime(28725): at java.lang.reflect.Method.invoke(Method.java:511)
11-14 19:10:02.100: E/AndroidRuntime(28725): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:817)
11-14 19:10:02.100: E/AndroidRuntime(28725): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:584)
11-14 19:10:02.100: E/AndroidRuntime(28725): at dalvik.system.NativeStart.main(Native Method)
11-14 19:10:02.100: E/AndroidRuntime(28725): Caused by: java.lang.ClassNotFoundException: com.fuad.traffic.MainActivity
11-14 19:10:02.100: E/AndroidRuntime(28725): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
11-14 19:10:02.100: E/AndroidRuntime(28725): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
11-14 19:10:02.100: E/AndroidRuntime(28725): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
11-14 19:10:02.100: E/AndroidRuntime(28725): at android.app.Instrumentation.newActivity(Instrumentation.java:1023)
11-14 19:10:02.100: E/AndroidRuntime(28725): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1871)
11-14 19:10:02.100: E/AndroidRuntime(28725): ... 11 more
thanx for master in stackoverflow.com :D
after importing appcompat_v7 check its properties android section and be sure that Is Library is checked! and then add appcompat_v7 project to your project in your project > properties > android and then clean and rebuild your project!
Try:
Right Click on Package Explorer
Import
Android > Existing Android Code into Workspace > Next
Browse > ~/sdk/extras/android/support/v7/appcompat
Select the package. Checkbox "Copy projects into workspace" > Finish
Right Click in YOUR PROJECT > Properties > Android
In the section of Library > Add > appcompat > OK
Finally go to Project (in the menu of eclipse) > Clean ..
Tell us if you tried something and what happened
for #mohammad, i have found the problem, in properties>java build path>project, the problem is there are have folder appcompat. and it's must delete. and when i delete it it's work. but the next problem when i run the program is like this
'11-14 19:24:44.379: W/dalvikvm(29518): VFY: unable to resolve virtual method 292: Landroid/app/Notification$Builder;.setPriority (I)Landroid/app/Notification$Builder;
11-14 19:24:44.379: W/dalvikvm(29518): threadid=1: thread exiting with uncaught exception (group=0x40b019f0)
11-14 19:24:44.389: E/AndroidRuntime(29518): FATAL EXCEPTION: main
11-14 19:24:44.389: E/AndroidRuntime(29518): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.fuad.traffic/com.fuad.traffic.MainActivity}: android.view.InflateException: Binary XML file line #15: Error inflating class fragment
11-14 19:24:44.389: E/AndroidRuntime(29518): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
11-14 19:24:44.389: E/AndroidRuntime(29518): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
11-14 19:24:44.389: E/AndroidRuntime(29518): at android.app.ActivityThread.access$600(ActivityThread.java:123)
11-14 19:24:44.389: E/AndroidRuntime(29518): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
11-14 19:24:44.389: E/AndroidRuntime(29518): at android.os.Handler.dispatchMessage(Handler.java:99)
11-14 19:24:44.389: E/AndroidRuntime(29518): at android.os.Looper.loop(Looper.java:137)
11-14 19:24:44.389: E/AndroidRuntime(29518): at android.app.ActivityThread.main(ActivityThread.java:4424)
11-14 19:24:44.389: E/AndroidRuntime(29518): at java.lang.reflect.Method.invokeNative(Native Method)
11-14 19:24:44.389: E/AndroidRuntime(29518): at java.lang.reflect.Method.invoke(Method.java:511)
11-14 19:24:44.389: E/AndroidRuntime(29518): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:817)
11-14 19:24:44.389: E/AndroidRuntime(29518): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:584)
11-14 19:24:44.389: E/AndroidRuntime(29518): at dalvik.system.NativeStart.main(Native Method)
11-14 19:24:44.389: E/AndroidRuntime(29518): Caused by: android.view.InflateException: Binary XML file line #15: Error inflating class fragment
11-14 19:24:44.389: E/AndroidRuntime(29518): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:697)
11-14 19:24:44.389: E/AndroidRuntime(29518): at android.view.LayoutInflater.rInflate(LayoutInflater.java:739)
11-14 19:24:44.389: E/AndroidRuntime(29518): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
11-14 19:24:44.389: E/AndroidRuntime(29518): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
11-14 19:24:44.389: E/AndroidRuntime(29518): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
11-14 19:24:44.389: E/AndroidRuntime(29518): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:268)
11-14 19:24:44.389: E/AndroidRuntime(29518): at android.app.Activity.setContentView(Activity.java:1837)
11-14 19:24:44.389: E/AndroidRuntime(29518): at com.fuad.traffic.MainActivity.onCreate(MainActivity.java:15)
11-14 19:24:44.389: E/AndroidRuntime(29518): at android.app.Activity.performCreate(Activity.java:4470)
11-14 19:24:44.389: E/AndroidRuntime(29518): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
11-14 19:24:44.389: E/AndroidRuntime(29518): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
11-14 19:24:44.389: E/AndroidRuntime(29518): ... 11 more
11-14 19:24:44.389: E/AndroidRuntime(29518): Caused by: java.lang.IllegalStateException: The meta-data tag in your app's AndroidManifest.xml does not have the right value. Expected 6111000 but found 0. You must have the following declaration within the <application> element: <meta-data android:name="com.google.android.gms.version" android:value="#integer/google_play_services_version" />
11-14 19:24:44.389: E/AndroidRuntime(29518): at com.google.android.gms.common.GooglePlayServicesUtil.E(Unknown Source)
11-14 19:24:44.389: E/AndroidRuntime(29518): at com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable(Unknown Source)
11-14 19:24:44.389: E/AndroidRuntime(29518): at com.google.android.gms.maps.internal.u.S(Unknown Source)
11-14 19:24:44.389: E/AndroidRuntime(29518): at com.google.android.gms.maps.internal.u.R(Unknown Source)
11-14 19:24:44.389: E/AndroidRuntime(29518): at com.google.android.gms.maps.MapsInitializer.initialize(Unknown Source)
11-14 19:24:44.389: E/AndroidRuntime(29518): at com.google.android.gms.maps.SupportMapFragment$b.my(Unknown Source)
11-14 19:24:44.389: E/AndroidRuntime(29518): at com.google.android.gms.maps.SupportMapFragment$b.a(Unknown Source)
11-14 19:24:44.389: E/AndroidRuntime(29518): at com.google.android.gms.dynamic.a.a(Unknown Source)
11-14 19:24:44.389: E/AndroidRuntime(29518): at com.google.android.gms.dynamic.a.onInflate(Unknown Source)
11-14 19:24:44.389: E/AndroidRuntime(29518): at com.google.android.gms.maps.SupportMapFragment.onInflate(Unknown Source)
11-14 19:24:44.389: E/AndroidRuntime(29518): at android.support.v4.app.FragmentManagerImpl.onCreateView(FragmentManager.java:2158)
11-14 19:24:44.389: E/AndroidRuntime(29518): at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:297)
11-14 19:24:44.389: E/AndroidRuntime(29518): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:669)
11-14 19:24:44.389: E/AndroidRuntime(29518): ... 21 more
'

ScrollView: java.lang.StackOverflowError

I got a ScrollView with many Views and if i start the activity i got this after some scrolling:
04-10 20:11:42.480: E/AndroidRuntime(2089): FATAL EXCEPTION: main
04-10 20:11:42.480: E/AndroidRuntime(2089): java.lang.StackOverflowError
04-10 20:11:42.480: E/AndroidRuntime(2089): at android.view.View.addFocusables(View.java:3654)
04-10 20:11:42.480: E/AndroidRuntime(2089): at android.view.ViewGroup.addFocusables(ViewGroup.java:637)
04-10 20:11:42.480: E/AndroidRuntime(2089): at android.view.ViewGroup.addFocusables(ViewGroup.java:637)
04-10 20:11:42.480: E/AndroidRuntime(2089): at android.view.ViewGroup.addFocusables(ViewGroup.java:637)
04-10 20:11:42.480: E/AndroidRuntime(2089): at android.view.ViewGroup.addFocusables(ViewGroup.java:637)
04-10 20:11:42.480: E/AndroidRuntime(2089): at android.view.ViewGroup.addFocusables(ViewGroup.java:637)
04-10 20:11:42.480: E/AndroidRuntime(2089): at android.view.ViewGroup.addFocusables(ViewGroup.java:637)
04-10 20:11:42.480: E/AndroidRuntime(2089): at android.view.ViewGroup.addFocusables(ViewGroup.java:637)
04-10 20:11:42.480: E/AndroidRuntime(2089): at android.view.ViewGroup.addFocusables(ViewGroup.java:637)
04-10 20:11:42.480: E/AndroidRuntime(2089): at android.view.ViewGroup.addFocusables(ViewGroup.java:637)
04-10 20:11:42.480: E/AndroidRuntime(2089): at android.view.ViewGroup.addFocusables(ViewGroup.java:637)
04-10 20:11:42.480: E/AndroidRuntime(2089): at android.view.ViewGroup.addFocusables(ViewGroup.java:618)
04-10 20:11:42.480: E/AndroidRuntime(2089): at android.view.View.getFocusables(View.java:3612)
04-10 20:11:42.480: E/AndroidRuntime(2089): at android.view.FocusFinder.findNextFocus(FocusFinder.java:109)
04-10 20:11:42.480: E/AndroidRuntime(2089): at android.view.FocusFinder.findNextFocus(FocusFinder.java:93)
04-10 20:11:42.480: E/AndroidRuntime(2089): at android.view.ViewGroup.focusSearch(ViewGroup.java:476)
04-10 20:11:42.480: E/AndroidRuntime(2089): at android.view.ViewGroup.focusSearch(ViewGroup.java:478)
04-10 20:11:42.480: E/AndroidRuntime(2089): at android.view.ViewGroup.focusSearch(ViewGroup.java:478)
04-10 20:11:42.480: E/AndroidRuntime(2089): at android.view.ViewGroup.focusSearch(ViewGroup.java:478)
04-10 20:11:42.480: E/AndroidRuntime(2089): at android.view.ViewGroup.focusSearch(ViewGroup.java:478)
04-10 20:11:42.480: E/AndroidRuntime(2089): at android.view.ViewGroup.focusSearch(ViewGroup.java:478)
04-10 20:11:42.480: E/AndroidRuntime(2089): at android.view.ViewGroup.focusSearch(ViewGroup.java:478)
04-10 20:11:42.480: E/AndroidRuntime(2089): at android.view.ViewGroup.focusSearch(ViewGroup.java:478)
04-10 20:11:42.480: E/AndroidRuntime(2089): at android.view.ViewGroup.focusSearch(ViewGroup.java:478)
04-10 20:11:42.480: E/AndroidRuntime(2089): at android.view.ViewGroup.focusSearch(ViewGroup.java:478)
04-10 20:11:42.480: E/AndroidRuntime(2089): at android.view.ViewGroup.focusSearch(ViewGroup.java:478)
04-10 20:11:42.480: E/AndroidRuntime(2089): at android.view.ViewGroup.focusSearch(ViewGroup.java:478)
04-10 20:11:42.480: E/AndroidRuntime(2089): at android.view.View.focusSearch(View.java:3547)
04-10 20:11:42.480: E/AndroidRuntime(2089): at android.widget.TextView.onCreateInputConnection(TextView.java:4662)
04-10 20:11:42.480: E/AndroidRuntime(2089): at android.view.inputmethod.InputMethodManager.startInputInner(InputMethodManager.java:945)
04-10 20:11:42.480: E/AndroidRuntime(2089): at android.view.inputmethod.InputMethodManager.checkFocus(InputMethodManager.java:1129)
04-10 20:11:42.480: E/AndroidRuntime(2089): at android.view.inputmethod.InputMethodManager.isActive(InputMethodManager.java:542)
04-10 20:11:42.480: E/AndroidRuntime(2089): at android.widget.TextView.onDraw(TextView.java:4173)
04-10 20:11:42.480: E/AndroidRuntime(2089): at android.view.View.draw(View.java:6933)
04-10 20:11:42.480: E/AndroidRuntime(2089): at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
04-10 20:11:42.480: E/AndroidRuntime(2089): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
04-10 20:11:42.480: E/AndroidRuntime(2089): at android.view.View.draw(View.java:6936)
04-10 20:11:42.480: E/AndroidRuntime(2089): at android.widget.FrameLayout.draw(FrameLayout.java:357)
04-10 20:11:42.480: E/AndroidRuntime(2089): at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
04-10 20:11:42.480: E/AndroidRuntime(2089): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
04-10 20:11:42.480: E/AndroidRuntime(2089): at android.view.View.draw(View.java:6936)
04-10 20:11:42.480: E/AndroidRuntime(2089): at android.widget.FrameLayout.draw(FrameLayout.java:357)
04-10 20:11:42.480: E/AndroidRuntime(2089): at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
04-10 20:11:42.480: E/AndroidRuntime(2089): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
04-10 20:11:42.480: E/AndroidRuntime(2089): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
04-10 20:11:42.480: E/AndroidRuntime(2089): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
04-10 20:11:42.480: E/AndroidRuntime(2089): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
04-10 20:11:42.480: E/AndroidRuntime(2089): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
04-10 20:11:42.480: E/AndroidRuntime(2089): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
04-10 20:11:42.480: E/AndroidRuntime(2089): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
04-10 20:11:42.480: E/AndroidRuntime(2089): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
04-10 20:11:42.480: E/AndroidRuntime(2089): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
04-10 20:11:42.480: E/AndroidRuntime(2089): at android.view.View.draw(View.java:7039)
04-10 20:11:42.480: E/AndroidRuntime(2089): at android.widget.FrameLayout.draw(FrameLayout.java:357)
04-10 20:11:42.480: E/AndroidRuntime(2089): at android.widget.ScrollView.draw(ScrollView.java:1415)
04-10 20:11:42.480: E/AndroidRuntime(2089): at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
04-10 20:11:42.480: E/AndroidRuntime(2089): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
04-10 20:11:42.480: E/AndroidRuntime(2089): at android.view.View.draw(View.java:6936)
04-10 20:11:42.480: E/AndroidRuntime(2089): at android.widget.FrameLayout.draw(FrameLayout.java:357)
04-10 20:11:42.480: E/AndroidRuntime(2089): at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
04-10 20:11:42.480: E/AndroidRuntime(2089): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
04-10 20:11:42.480: E/AndroidRuntime(2089): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
04-10 20:11:42.480: E/AndroidRuntime(2089): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
04-10 20:11:42.480: E/AndroidRuntime(2089): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
04-10 20:11:42.480: E/AndroidRuntime(2089): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
04-10 20:11:42.480: E/AndroidRuntime(2089): at android.view.View.draw(View.java:6936)
04-10 20:11:42.480: E/AndroidRuntime(2089): at android.widget.FrameLayout.draw(FrameLayout.java:357)
04-10 20:11:42.480: E/AndroidRuntime(2089): at android.view.ViewGroup.drawChild(
Why m I getting this error any idea?
Your UI View tree is too deep. addFocusables is recursive (obviously) into the View layout tree and Android has a fairly limited stack size. Change your layout to do less nesting and more of a flat layout. You may need to write a custom layout to get the layout you want without nesting.

Android httpget does not work properly

I am having a problem executing an url via httpget in android.
try
{
DefaultHttpClient client = new DefaultHttpClient();
HttpGet getURL = new HttpGet("http://www.example.com/index.php?text=x");
client.execute(getURL);
Toast.makeText(this.getBaseContext(), "I'm here", Toast.LENGTH_LONG).show();
} catch (Exception e) {
Toast.makeText(this.getBaseContext(), "Code Failed:" + e.getLocalizedMessage(), Toast.LENGTH_LONG).show();
}
For some Reason my app wil show a Toeast with the message: "Code Failed: Null".
I just want to execute an URL. When the URL is called my php file will update a record in the database. I just want to update/insert databases in my mysql database. So parsing json/xml/other response is not necessary.
If I show my exceptions in the logcat, this is what I see:
11-14 13:56:39.255: E/MYAPP(19638): exception
11-14 13:56:39.255: E/MYAPP(19638): android.os.NetworkOnMainThreadException
11-14 13:56:39.255: E/MYAPP(19638): at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1118)
11-14 13:56:39.255: E/MYAPP(19638): at java.net.InetAddress.lookupHostByName(InetAddress.java:385)
11-14 13:56:39.255: E/MYAPP(19638): at java.net.InetAddress.getAllByNameImpl(InetAddress.java:236)
11-14 13:56:39.255: E/MYAPP(19638): at java.net.InetAddress.getAllByName(InetAddress.java:214)
11-14 13:56:39.255: E/MYAPP(19638): at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:137)
11-14 13:56:39.255: E/MYAPP(19638): at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
11-14 13:56:39.255: E/MYAPP(19638): at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
11-14 13:56:39.255: E/MYAPP(19638): at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:360)
11-14 13:56:39.255: E/MYAPP(19638): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:670)
11-14 13:56:39.255: E/MYAPP(19638): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:509)
11-14 13:56:39.255: E/MYAPP(19638): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
11-14 13:56:39.255: E/MYAPP(19638): at com.thepl.shopapp.MainActivity.onCreate(MainActivity.java:156)
11-14 13:56:39.255: E/MYAPP(19638): at android.app.Activity.performCreate(Activity.java:5184)
11-14 13:56:39.255: E/MYAPP(19638): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1083)
11-14 13:56:39.255: E/MYAPP(19638): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2064)
11-14 13:56:39.255: E/MYAPP(19638): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2125)
11-14 13:56:39.255: E/MYAPP(19638): at android.app.ActivityThread.access$600(ActivityThread.java:140)
11-14 13:56:39.255: E/MYAPP(19638): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1227)
11-14 13:56:39.255: E/MYAPP(19638): at android.os.Handler.dispatchMessage(Handler.java:99)
11-14 13:56:39.255: E/MYAPP(19638): at android.os.Looper.loop(Looper.java:137)
11-14 13:56:39.255: E/MYAPP(19638): at android.app.ActivityThread.main(ActivityThread.java:4898)
11-14 13:56:39.255: E/MYAPP(19638): at java.lang.reflect.Method.invokeNative(Native Method)
11-14 13:56:39.255: E/MYAPP(19638): at java.lang.reflect.Method.invoke(Method.java:511)
11-14 13:56:39.255: E/MYAPP(19638): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006)
11-14 13:56:39.255: E/MYAPP(19638): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
11-14 13:56:39.255: E/MYAPP(19638): at dalvik.system.NativeStart.main(Native Method)
11-14 13:56:58.205: E/MYAPP(19638): exception
11-14 13:56:58.205: E/MYAPP(19638): android.os.NetworkOnMainThreadException
11-14 13:56:58.205: E/MYAPP(19638): at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1118)
11-14 13:56:58.205: E/MYAPP(19638): at java.net.InetAddress.lookupHostByName(InetAddress.java:385)
11-14 13:56:58.205: E/MYAPP(19638): at java.net.InetAddress.getAllByNameImpl(InetAddress.java:236)
11-14 13:56:58.205: E/MYAPP(19638): at java.net.InetAddress.getAllByName(InetAddress.java:214)
11-14 13:56:58.205: E/MYAPP(19638): at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:137)
11-14 13:56:58.205: E/MYAPP(19638): at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
11-14 13:56:58.205: E/MYAPP(19638): at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
11-14 13:56:58.205: E/MYAPP(19638): at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:360)
11-14 13:56:58.205: E/MYAPP(19638): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:670)
11-14 13:56:58.205: E/MYAPP(19638): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:509)
11-14 13:56:58.205: E/MYAPP(19638): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
11-14 13:56:58.205: E/MYAPP(19638): at com.thepl.shopapp.MainActivity.onCreate(MainActivity.java:156)
11-14 13:56:58.205: E/MYAPP(19638): at android.app.Activity.performCreate(Activity.java:5184)
11-14 13:56:58.205: E/MYAPP(19638): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1083)
11-14 13:56:58.205: E/MYAPP(19638): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2064)
11-14 13:56:58.205: E/MYAPP(19638): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2125)
11-14 13:56:58.205: E/MYAPP(19638): at android.app.ActivityThread.access$600(ActivityThread.java:140)
11-14 13:56:58.205: E/MYAPP(19638): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1227)
11-14 13:56:58.205: E/MYAPP(19638): at android.os.Handler.dispatchMessage(Handler.java:99)
11-14 13:56:58.205: E/MYAPP(19638): at android.os.Looper.loop(Looper.java:137)
11-14 13:56:58.205: E/MYAPP(19638): at android.app.ActivityThread.main(ActivityThread.java:4898)
11-14 13:56:58.205: E/MYAPP(19638): at java.lang.reflect.Method.invokeNative(Native Method)
11-14 13:56:58.205: E/MYAPP(19638): at java.lang.reflect.Method.invoke(Method.java:511)
11-14 13:56:58.205: E/MYAPP(19638): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006)
11-14 13:56:58.205: E/MYAPP(19638): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
11-14 13:56:58.205: E/MYAPP(19638): at dalvik.system.NativeStart.main(Native Method)
11-14 13:56:59.100: E/MYAPP(19638): exception
11-14 13:56:59.100: E/MYAPP(19638): android.os.NetworkOnMainThreadException
11-14 13:56:59.100: E/MYAPP(19638): at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1118)
11-14 13:56:59.100: E/MYAPP(19638): at java.net.InetAddress.lookupHostByName(InetAddress.java:385)
11-14 13:56:59.100: E/MYAPP(19638): at java.net.InetAddress.getAllByNameImpl(InetAddress.java:236)
11-14 13:56:59.100: E/MYAPP(19638): at java.net.InetAddress.getAllByName(InetAddress.java:214)
11-14 13:56:59.100: E/MYAPP(19638): at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:137)
11-14 13:56:59.100: E/MYAPP(19638): at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
11-14 13:56:59.100: E/MYAPP(19638): at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
11-14 13:56:59.100: E/MYAPP(19638): at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:360)
11-14 13:56:59.100: E/MYAPP(19638): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:670)
11-14 13:56:59.100: E/MYAPP(19638): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:509)
11-14 13:56:59.100: E/MYAPP(19638): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
11-14 13:56:59.100: E/MYAPP(19638): at com.thepl.shopapp.MainActivity.onCreate(MainActivity.java:156)
11-14 13:56:59.100: E/MYAPP(19638): at android.app.Activity.performCreate(Activity.java:5184)
11-14 13:56:59.100: E/MYAPP(19638): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1083)
11-14 13:56:59.100: E/MYAPP(19638): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2064)
11-14 13:56:59.100: E/MYAPP(19638): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2125)
11-14 13:56:59.100: E/MYAPP(19638): at android.app.ActivityThread.access$600(ActivityThread.java:140)
11-14 13:56:59.100: E/MYAPP(19638): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1227)
11-14 13:56:59.100: E/MYAPP(19638): at android.os.Handler.dispatchMessage(Handler.java:99)
11-14 13:56:59.100: E/MYAPP(19638): at android.os.Looper.loop(Looper.java:137)
11-14 13:56:59.100: E/MYAPP(19638): at android.app.ActivityThread.main(ActivityThread.java:4898)
11-14 13:56:59.100: E/MYAPP(19638): at java.lang.reflect.Method.invokeNative(Native Method)
11-14 13:56:59.100: E/MYAPP(19638): at java.lang.reflect.Method.invoke(Method.java:511)
11-14 13:56:59.100: E/MYAPP(19638): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006)
11-14 13:56:59.100: E/MYAPP(19638): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
11-14 13:56:59.100: E/MYAPP(19638): at dalvik.system.NativeStart.main(Native Method)
11-14 13:57:21.185: E/MYAPP(19638): exception
11-14 13:57:21.185: E/MYAPP(19638): android.os.NetworkOnMainThreadException
11-14 13:57:21.185: E/MYAPP(19638): at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1118)
11-14 13:57:21.185: E/MYAPP(19638): at java.net.InetAddress.lookupHostByName(InetAddress.java:385)
11-14 13:57:21.185: E/MYAPP(19638): at java.net.InetAddress.getAllByNameImpl(InetAddress.java:236)
11-14 13:57:21.185: E/MYAPP(19638): at java.net.InetAddress.getAllByName(InetAddress.java:214)
11-14 13:57:21.185: E/MYAPP(19638): at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:137)
11-14 13:57:21.185: E/MYAPP(19638): at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
11-14 13:57:21.185: E/MYAPP(19638): at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
11-14 13:57:21.185: E/MYAPP(19638): at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:360)
11-14 13:57:21.185: E/MYAPP(19638): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:670)
11-14 13:57:21.185: E/MYAPP(19638): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:509)
11-14 13:57:21.185: E/MYAPP(19638): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
11-14 13:57:21.185: E/MYAPP(19638): at com.thepl.shopapp.MainActivity.onCreate(MainActivity.java:156)
11-14 13:57:21.185: E/MYAPP(19638): at android.app.Activity.performCreate(Activity.java:5184)
11-14 13:57:21.185: E/MYAPP(19638): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1083)
11-14 13:57:21.185: E/MYAPP(19638): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2064)
11-14 13:57:21.185: E/MYAPP(19638): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2125)
11-14 13:57:21.185: E/MYAPP(19638): at android.app.ActivityThread.access$600(ActivityThread.java:140)
11-14 13:57:21.185: E/MYAPP(19638): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1227)
11-14 13:57:21.185: E/MYAPP(19638): at android.os.Handler.dispatchMessage(Handler.java:99)
11-14 13:57:21.185: E/MYAPP(19638): at android.os.Looper.loop(Looper.java:137)
11-14 13:57:21.185: E/MYAPP(19638): at android.app.ActivityThread.main(ActivityThread.java:4898)
11-14 13:57:21.185: E/MYAPP(19638): at java.lang.reflect.Method.invokeNative(Native Method)
11-14 13:57:21.185: E/MYAPP(19638): at java.lang.reflect.Method.invoke(Method.java:511)
11-14 13:57:21.185: E/MYAPP(19638): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006)
11-14 13:57:21.185: E/MYAPP(19638): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
11-14 13:57:21.185: E/MYAPP(19638): at dalvik.system.NativeStart.main(Native Method)
you should make network call on main UI thread. following is the definition of the exception:
The exception that is thrown when an application attempts to perform a
networking operation on its main thread.
This is only thrown for applications targeting the Honeycomb SDK or
higher. Applications targeting earlier SDK versions are allowed to do
networking on their main event loop threads, but it's heavily
discouraged.
check out my answer on following post for solution:
Can java.util.zip.GZIPInputStream.close cause android.os.NetworkOnMainThreadException
Seems like the stacktrace is pretty useful. Strictmode is on which will throw an exception if you try doing long-running work on the main (UI) thread.
There are two rules to the Android threading model:
Don't do long work on the main thread
Don't update the UI from outside of the UI thread
You have violated the first of these rules.

While retriveing Data from data base shows NUll POINTER EXCEPTION

Since , I am new in android world so , please help me. When i am working with Android SQLite for retrieving data from data-base by these codes-
Cursor cursor;
DatabaseConnector dbConnector = new DatabaseConnector(this);
private ListAdapter conAdapter;
String[] from_for_text_in_list = {"name"};
int[] to_for_text_in_list = {R.id.title_info_txt_v}
cursor = dbConnector.getAllContacts();
conAdapter = new SimpleCursorAdapter(Infoclass.this, R.layout.listview_layout, null, from_for_text_in_list, to_for_text_in_list);
setListAdapter(conAdapter);
Now i declare getAllmethod() as-
public Cursor getAllContacts()
{
return database.rawQuery("SELECT _id, name FROM tcc_info_table ", new String[]{"_id", "name"});
}
"name" is just a column name of database in my App.
While I am running my App it shows NULL POINTER Exception in getAllContact() method . Even i check my database through SQLite Browser and i found that data insertion going on successfully . But data not retrieve from database to list view . My logCat error is as below-
11-14 12:01:21.694: E/Trace(30607): error opening trace file: No such file or directory (2)
11-14 12:01:22.475: D/AndroidRuntime(30607): Shutting down VM
11-14 12:01:22.475: W/dalvikvm(30607): threadid=1: thread exiting with uncaught exception (group=0x40a13300)
11-14 12:01:22.495: E/AndroidRuntime(30607): FATAL EXCEPTION: main
11-14 12:01:22.495: E/AndroidRuntime(30607): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.kt.narendramodi/com.kt.narendramodi.ModiForIndia}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.kt.narendramodi/com.kt.narendramodi.InfoNarendraModi}: java.lang.IllegalArgumentException: Cannot bind argument at index 2 because the index is out of range. The statement has 0 parameters.
11-14 12:01:22.495: E/AndroidRuntime(30607): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
11-14 12:01:22.495: E/AndroidRuntime(30607): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
11-14 12:01:22.495: E/AndroidRuntime(30607): at android.app.ActivityThread.access$600(ActivityThread.java:130)
11-14 12:01:22.495: E/AndroidRuntime(30607): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
11-14 12:01:22.495: E/AndroidRuntime(30607): at android.os.Handler.dispatchMessage(Handler.java:99)
11-14 12:01:22.495: E/AndroidRuntime(30607): at android.os.Looper.loop(Looper.java:137)
11-14 12:01:22.495: E/AndroidRuntime(30607): at android.app.ActivityThread.main(ActivityThread.java:4745)
11-14 12:01:22.495: E/AndroidRuntime(30607): at java.lang.reflect.Method.invokeNative(Native Method)
11-14 12:01:22.495: E/AndroidRuntime(30607): at java.lang.reflect.Method.invoke(Method.java:511)
11-14 12:01:22.495: E/AndroidRuntime(30607): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
11-14 12:01:22.495: E/AndroidRuntime(30607): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
11-14 12:01:22.495: E/AndroidRuntime(30607): at dalvik.system.NativeStart.main(Native Method)
11-14 12:01:22.495: E/AndroidRuntime(30607): Caused by: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.kt.narendramodi/com.kt.narendramodi.InfoNarendraModi}: java.lang.IllegalArgumentException: Cannot bind argument at index 2 because the index is out of range. The statement has 0 parameters.
11-14 12:01:22.495: E/AndroidRuntime(30607): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
11-14 12:01:22.495: E/AndroidRuntime(30607): at android.app.ActivityThread.startActivityNow(ActivityThread.java:1900)
11-14 12:01:22.495: E/AndroidRuntime(30607): at android.app.LocalActivityManager.moveToState(LocalActivityManager.java:135)
11-14 12:01:22.495: E/AndroidRuntime(30607): at android.app.LocalActivityManager.startActivity(LocalActivityManager.java:347)
11-14 12:01:22.495: E/AndroidRuntime(30607): at android.widget.TabHost$IntentContentStrategy.getContentView(TabHost.java:694)
11-14 12:01:22.495: E/AndroidRuntime(30607): at android.widget.TabHost.setCurrentTab(TabHost.java:358)
11-14 12:01:22.495: E/AndroidRuntime(30607): at android.widget.TabHost.addTab(TabHost.java:236)
11-14 12:01:22.495: E/AndroidRuntime(30607): at com.kt.narendramodi.ModiForIndia.onCreate(ModiForIndia.java:41)
11-14 12:01:22.495: E/AndroidRuntime(30607): at android.app.Activity.performCreate(Activity.java:5008)
11-14 12:01:22.495: E/AndroidRuntime(30607): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
11-14 12:01:22.495: E/AndroidRuntime(30607): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
11-14 12:01:22.495: E/AndroidRuntime(30607): ... 11 more
11-14 12:01:22.495: E/AndroidRuntime(30607): Caused by: java.lang.IllegalArgumentException: Cannot bind argument at index 2 because the index is out of range. The statement has 0 parameters.
11-14 12:01:22.495: E/AndroidRuntime(30607): at android.database.sqlite.SQLiteProgram.bind(SQLiteProgram.java:212)
11-14 12:01:22.495: E/AndroidRuntime(30607): at android.database.sqlite.SQLiteProgram.bindString(SQLiteProgram.java:166)
11-14 12:01:22.495: E/AndroidRuntime(30607): at android.database.sqlite.SQLiteProgram.bindAllArgsAsStrings(SQLiteProgram.java:200)
11-14 12:01:22.495: E/AndroidRuntime(30607): at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:47)
11-14 12:01:22.495: E/AndroidRuntime(30607): at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1314)
11-14 12:01:22.495: E/AndroidRuntime(30607): at android.database.sqlite.SQLiteDatabase.rawQuery(SQLiteDatabase.java:1253)
11-14 12:01:22.495: E/AndroidRuntime(30607): at com.kt.nanrendramodi.databasehelper.DatabaseConnector.getAllContacts(DatabaseConnector.java:60)
11-14 12:01:22.495: E/AndroidRuntime(30607): at com.kt.narendramodi.InfoNarendraModi.onCreate(InfoNarendraModi.java:94)
11-14 12:01:22.495: E/AndroidRuntime(30607): at android.app.Activity.performCreate(Activity.java:5008)
11-14 12:01:22.495: E/AndroidRuntime(30607): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
11-14 12:01:22.495: E/AndroidRuntime(30607): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
11-14 12:01:22.495: E/AndroidRuntime(30607): ... 21 more
You'll have to check 2 things:
Your database should be initialized to a read/write-able database.
database = yourDbHelper.getReadableDatabase();
You don't need those selection arguments if you've filled the SQL query fully.
database.rawQuery("SELECT _id, name FROM tcc_info_table ", null);

Categories

Resources