Adding custom views dynamically in RelativeLayout - android

I am trying to add a custom view from xml to a RelativeLayout inside a ScrollView.
The custom View contains a couple of TextView. I set the text of the TextViews and set the width, height and topMargin of the view and add it to the relativeLayout. But i keep getting error and i dont know why.
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
RelativeLayout board = (RelativeLayout) findViewById(R.id.Dashboard);
List<Data> dummyData = new InitData().getDummyData();
for (Data data : dummyData) {
View view = null;
LayoutInflater inflater = LayoutInflater.from(MainActivity.this);
view = inflater.inflate(R.layout.my_view, board);
TextView titleTextView = (TextView) view
.findViewById(R.id.title_text_view);
titleTextView.setText(data.getTitle()); //I think error occurs here
int width = LayoutParams.MATCH_PARENT;
int height = data.getHeight();
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
width, height);
params.topMargin = data.getTopMargin();
view.setLayoutParams(params);
}
}
LogCat Error
02-21 20:33:56.903: E/AndroidRuntime(3322): FATAL EXCEPTION: main
02-21 20:33:56.903: E/AndroidRuntime(3322): java.lang.ClassCastException: android.widget.RelativeLayout$LayoutParams
02-21 20:33:56.903: E/AndroidRuntime(3322): at android.widget.LinearLayout.measureHorizontal(LinearLayout.java:654)
02-21 20:33:56.903: E/AndroidRuntime(3322): at android.widget.LinearLayout.onMeasure(LinearLayout.java:306)
02-21 20:33:56.903: E/AndroidRuntime(3322): at android.view.View.measure(View.java:8171)
02-21 20:33:56.903: E/AndroidRuntime(3322): at android.widget.ScrollView.measureChildWithMargins(ScrollView.java:989)
02-21 20:33:56.903: E/AndroidRuntime(3322): at android.widget.FrameLayout.onMeasure(FrameLayout.java:245)
02-21 20:33:56.903: E/AndroidRuntime(3322): at android.widget.ScrollView.onMeasure(ScrollView.java:286)
02-21 20:33:56.903: E/AndroidRuntime(3322): at android.view.View.measure(View.java:8171)
02-21 20:33:56.903: E/AndroidRuntime(3322): at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:578)
02-21 20:33:56.903: E/AndroidRuntime(3322): at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:362)
02-21 20:33:56.903: E/AndroidRuntime(3322): at android.view.View.measure(View.java:8171)
02-21 20:33:56.903: E/AndroidRuntime(3322): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3132)
02-21 20:33:56.903: E/AndroidRuntime(3322): at android.widget.FrameLayout.onMeasure(FrameLayout.java:245)
02-21 20:33:56.903: E/AndroidRuntime(3322): at android.view.View.measure(View.java:8171)
02-21 20:33:56.903: E/AndroidRuntime(3322): at android.widget.LinearLayout.measureVertical(LinearLayout.java:526)
02-21 20:33:56.903: E/AndroidRuntime(3322): at android.widget.LinearLayout.onMeasure(LinearLayout.java:304)
02-21 20:33:56.903: E/AndroidRuntime(3322): at android.view.View.measure(View.java:8171)
02-21 20:33:56.903: E/AndroidRuntime(3322): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3132)
02-21 20:33:56.903: E/AndroidRuntime(3322): at android.widget.FrameLayout.onMeasure(FrameLayout.java:245)
02-21 20:33:56.903: E/AndroidRuntime(3322): at android.view.View.measure(View.java:8171)
02-21 20:33:56.903: E/AndroidRuntime(3322): at android.view.ViewRoot.performTraversals(ViewRoot.java:801)
02-21 20:33:56.903: E/AndroidRuntime(3322): at android.view.ViewRoot.handleMessage(ViewRoot.java:1727)
02-21 20:33:56.903: E/AndroidRuntime(3322): at android.os.Handler.dispatchMessage(Handler.java:99)
02-21 20:33:56.903: E/AndroidRuntime(3322): at android.os.Looper.loop(Looper.java:123)
02-21 20:33:56.903: E/AndroidRuntime(3322): at android.app.ActivityThread.main(ActivityThread.java:4627)
02-21 20:33:56.903: E/AndroidRuntime(3322): at java.lang.reflect.Method.invokeNative(Native Method)
02-21 20:33:56.903: E/AndroidRuntime(3322): at java.lang.reflect.Method.invoke(Method.java:521)
02-21 20:33:56.903: E/AndroidRuntime(3322): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
02-21 20:33:56.903: E/AndroidRuntime(3322): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
02-21 20:33:56.903: E/AndroidRuntime(3322): at dalvik.system.NativeStart.main(Native Method)
R.layout.my_view
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="#+id/title_text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:id="#+id/data_text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>

Looks like you're using the wrong kind of LayoutParams. Be aware, that the LayoutParams must match the parent view you're adding your children to. So if you have e.g. a LinearLayout and want to add a RelativeLayout to it, you have to use the LinearLayout.LayoutParams, not the RelativeLayout.LayoutParams.

Related

android 4.0.3 ScrollingTabContainerView NullPointerException

Our Android Application randomly crashes (very hard to repro the issue) with the following stack trace . This is seen when the orientation of the device is changed from portrait to landscape from the logcat logs. Also this issue has been seen on devices with Android 4.0.3 version. So wanted to check if it is a known issue with 4.0.3? Not sure from the code how to debug this issue as the stack trace is entirely of Android platform with no involvement of App code.
02-21 17:44:01.761 E/UncaughtException( 3344): java.lang.NullPointerException
02-21 17:44:01.761 E/UncaughtException( 3344): at com.android.internal.widget.ScrollingTabContainerView.onItemSelected(ScrollingTabContainerView.java:352)
02-21 17:44:01.761 E/UncaughtException( 3344): at android.widget.AdapterView.fireOnSelected(AdapterView.java:882)
02-21 17:44:01.761 E/UncaughtException( 3344): at android.widget.AdapterView.selectionChanged(AdapterView.java:865)
02-21 17:44:01.761 E/UncaughtException( 3344): at android.widget.AdapterView.checkSelectionChanged(AdapterView.java:1017)
02-21 17:44:01.761 E/UncaughtException( 3344): at android.widget.AdapterView.handleDataChanged(AdapterView.java:999)
02-21 17:44:01.761 E/UncaughtException( 3344): at android.widget.AbsSpinner.onMeasure(AbsSpinner.java:179)
02-21 17:44:01.761 E/UncaughtException( 3344): at android.widget.Spinner.onMeasure(Spinner.java:285)
02-21 17:44:01.761 E/UncaughtException( 3344): at android.view.View.measure(View.java:12723)
02-21 17:44:01.761 E/UncaughtException( 3344): at android.widget.HorizontalScrollView.measureChildWithMargins(HorizontalScrollView.java:1159)
02-21 17:44:01.761 E/UncaughtException( 3344): at android.widget.FrameLayout.onMeasure(FrameLayout.java:293)
02-21 17:44:01.761 E/UncaughtException( 3344): at android.widget.HorizontalScrollView.onMeasure(HorizontalScrollView.java:303)
02-21 17:44:01.761 E/UncaughtException( 3344): at com.android.internal.widget.ScrollingTabContainerView.onMeasure(ScrollingTabContainerView.java:117)
02-21 17:44:01.761 E/UncaughtException( 3344): at android.view.View.measure(View.java:12723)
02-21 17:44:01.761 E/UncaughtException( 3344): at com.android.internal.widget.ActionBarView.onMeasure(ActionBarView.java:878)
02-21 17:44:01.761 E/UncaughtException( 3344): at android.view.View.measure(View.java:12723)
02-21 17:44:01.761 E/UncaughtException( 3344): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4698)
02-21 17:44:01.761 E/UncaughtException( 3344): at android.widget.FrameLayout.onMeasure(FrameLayout.java:293)
02-21 17:44:01.761 E/UncaughtException( 3344): at com.android.internal.widget.ActionBarContainer.onMeasure(ActionBarContainer.java:173)
02-21 17:44:01.761 E/UncaughtException( 3344): at android.view.View.measure(View.java:12723)
02-21 17:44:01.761 E/UncaughtException( 3344): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4698)
02-21 17:44:01.761 E/UncaughtException( 3344): at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1369)
02-21 17:44:01.761 E/UncaughtException( 3344): at android.widget.LinearLayout.measureVertical(LinearLayout.java:660)
02-21 17:44:01.761 E/UncaughtException( 3344): at android.widget.LinearLayout.onMeasure(LinearLayout.java:553)
02-21 17:44:01.761 E/UncaughtException( 3344): at android.view.View.measure(View.java:12723)
02-21 17:44:01.761 E/UncaughtException( 3344): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4698)
02-21 17:44:01.761 E/UncaughtException( 3344): at android.widget.FrameLayout.onMeasure(FrameLayout.java:293)
02-21 17:44:01.761 E/UncaughtException( 3344): at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2092)
02-21 17:44:01.761 E/UncaughtException( 3344): at android.view.View.measure(View.java:12723)
02-21 17:44:01.761 E/UncaughtException( 3344): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1064)
02-21 17:44:01.761 E/UncaughtException( 3344): at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2442)
02-21 17:44:01.761 E/UncaughtException( 3344): at android.os.Handler.dispatchMessage(Handler.java:99)
02-21 17:44:01.761 E/UncaughtException( 3344): at android.os.Looper.loop(Looper.java:137)
02-21 17:44:01.761 E/UncaughtException( 3344): at android.app.ActivityThread.main(ActivityThread.java:4424)
02-21 17:44:01.761 E/UncaughtException( 3344): at java.lang.reflect.Method.invokeNative(Native Method)
02-21 17:44:01.761 E/UncaughtException( 3344): at java.lang.reflect.Method.invoke(Method.java:511)
02-21 17:44:01.761 E/UncaughtException( 3344): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
02-21 17:44:01.761 E/UncaughtException( 3344): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
02-21 17:44:01.761 E/UncaughtException( 3344): at dalvik.system.NativeStart.main(Native Method)
I really have no clue where this error is coming from. I fixed it by changing
<item name="android:windowActionBarOverlay">false</item>
into
<item name="android:windowActionBarOverlay">true</item>
in my main style for Android v15. It makes my app a little less beautiful for this Android version, but that is alright. I hope it's only a 4.0.3 bug, I have 6 tablets with other Android versions that are doing fine.

apk failed to install & logcat shows NoSuchMethodException

As mentioned in the title, when compiling, the Console says: Failed to install ap.apk
But the logcat shows this:
02-21 00:45:25.052: W/dalvikvm(921): threadid=1: thread exiting with uncaught exception (group=0x409c01f8)
02-21 00:45:25.272: E/AndroidRuntime(921): FATAL EXCEPTION: main
02-21 00:45:25.272: E/AndroidRuntime(921): java.lang.IllegalStateException: Could not find a method retour(View) in the activity class hd.android.contact.ContactActionActivity for onClick handler on view class android.widget.Button with id 'button5'
02-21 00:45:25.272: E/AndroidRuntime(921): at android.view.View$1.onClick(View.java:3031)
02-21 00:45:25.272: E/AndroidRuntime(921): at android.view.View.performClick(View.java:3511)
02-21 00:45:25.272: E/AndroidRuntime(921): at android.view.View$PerformClick.run(View.java:14105)
02-21 00:45:25.272: E/AndroidRuntime(921): at android.os.Handler.handleCallback(Handler.java:605)
02-21 00:45:25.272: E/AndroidRuntime(921): at android.os.Handler.dispatchMessage(Handler.java:92)
02-21 00:45:25.272: E/AndroidRuntime(921): at android.os.Looper.loop(Looper.java:137)
02-21 00:45:25.272: E/AndroidRuntime(921): at android.app.ActivityThread.main(ActivityThread.java:4424)
02-21 00:45:25.272: E/AndroidRuntime(921): at java.lang.reflect.Method.invokeNative(Native Method)
02-21 00:45:25.272: E/AndroidRuntime(921): at java.lang.reflect.Method.invoke(Method.java:511)
02-21 00:45:25.272: E/AndroidRuntime(921): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
02-21 00:45:25.272: E/AndroidRuntime(921): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
02-21 00:45:25.272: E/AndroidRuntime(921): at dalvik.system.NativeStart.main(Native Method)
**02-21 00:45:25.272: E/AndroidRuntime(921): Caused by: java.lang.NoSuchMethodException: retour [class android.view.View]**
02-21 00:45:25.272: E/AndroidRuntime(921): at java.lang.Class.getConstructorOrMethod(Class.java:460)
02-21 00:45:25.272: E/AndroidRuntime(921): at java.lang.Class.getMethod(Class.java:915)
02-21 00:45:25.272: E/AndroidRuntime(921): at android.view.View$1.onClick(View.java:3024)
I commented all my "retour" methods and deleted all android:onClick related to this method, and it did not help...Everything was working fine before...
Can anybody help please?
Thank you in advance
IllegalStateException: Could not find a method retour(View)
I think the problem is that you (definitely) have specified onClick on a method retour in the XML but the method
is not present in the Java code.
If the problem continues, try cleaning the project and shutting down your softphone.

i get allways this errors when i execute web service application, can you help me please?

02-21 14:00:32.442: W/WindowManager(88): Failure taking screenshot for (180x300) to layer 21010
02-21 14:00:32.621: W/NetworkManagementSocketTagger(88): setKernelCountSet(10004, 1) failed with errno -2
02-21 14:00:34.962: W/NetworkManagementSocketTagger(88): setKernelCountSet(10061, 0) failed with errno -2
02-21 14:00:38.403: D/AndroidRuntime(583): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
02-21 14:00:38.403: D/AndroidRuntime(583): CheckJNI is ON
02-21 14:00:40.521: D/AndroidRuntime(583): Calling main entry com.android.commands.pm.Pm
02-21 14:00:40.592: D/AndroidRuntime(583): Shutting down VM
02-21 14:00:40.611: I/AndroidRuntime(583): NOTE: attach of thread 'Binder Thread #3' failed
02-21 14:00:40.621: D/dalvikvm(583): GC_CONCURRENT freed 100K, 78% free 462K/2048K, paused 2ms+2ms
02-21 14:00:40.621: D/jdwp(583): Got wake-up signal, bailing out of select
02-21 14:00:40.621: D/dalvikvm(583): Debugger has detached; object registry had 1 entries
02-21 14:00:41.421: D/AndroidRuntime(596): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
02-21 14:00:41.421: D/AndroidRuntime(596): CheckJNI is ON
02-21 14:00:42.471: D/AndroidRuntime(596): Calling main entry com.android.commands.am.Am
02-21 14:00:42.521: I/ActivityManager(88): START {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.pfe/.SoappActivity} from pid 596
02-21 14:00:42.531: W/WindowManager(88): Failure taking screenshot for (180x300) to layer 21005
02-21 14:00:42.611: W/NetworkManagementSocketTagger(88): setKernelCountSet(10061, 1) failed with errno -2
02-21 14:00:43.221: W/System.err(536): at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:95)
02-21 14:00:42.661: I/AndroidRuntime(596): NOTE: attach of thread 'Binder Thread #3' failed
02-21 14:00:42.661: D/dalvikvm(596): GC_CONCURRENT freed 101K, 77% free 483K/2048K, paused 1ms+3ms
02-21 14:00:42.661: D/jdwp(596): Got wake-up signal, bailing out of select
02-21 14:00:42.671: D/dalvikvm(596): Debugger has detached; object registry had 1 entries
02-21 14:00:43.021: W/System.err(536): android.os.NetworkOnMainThreadException
02-21 14:00:43.021: W/System.err(536): at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1084)
02-21 14:00:43.071: W/System.err(536): at java.net.InetAddress.lookupHostByName(InetAddress.java:391)
02-21 14:00:43.071: W/System.err(536): at java.net.InetAddress.getAllByNameImpl(InetAddress.java:242)
02-21 14:00:43.081: W/System.err(536): at java.net.InetAddress.getAllByName(InetAddress.java:220)
02-21 14:00:43.081: W/System.err(536): at libcore.net.http.HttpConnection.<init>(HttpConnection.java:71)
02-21 14:00:43.081: W/System.err(536): at libcore.net.http.HttpConnection.<init>(HttpConnection.java:50)
02-21 14:00:43.127: W/System.err(536): at libcore.net.http.HttpConnection$Address.connect(HttpConnection.java:351)
02-21 14:00:43.127: W/System.err(536): at libcore.net.http.HttpConnectionPool.get(HttpConnectionPool.java:86)
02-21 14:00:43.131: W/System.err(536): at libcore.net.http.HttpConnection.connect(HttpConnection.java:128)
02-21 14:00:43.332: W/System.err(536): at dalvik.system.NativeStart.main(Native Method)
02-21 14:01:30.961: D/dalvikvm(536): GC_CONCURRENT freed 231K, 4% free 10112K/10503K, paused 23ms+23ms
02-21 14:04:36.751: D/gralloc_goldfish(640): Emulator without GPU emulation detected.
02-21 14:05:40.481: D/AndroidRuntime(640): Shutting down VM
02-21 14:05:40.481: W/dalvikvm(640): threadid=1: thread exiting with uncaught exception (group=0x409951f8)
02-21 14:05:40.571: E/AndroidRuntime(640): FATAL EXCEPTION: main
02-21 14:05:40.571: E/AndroidRuntime(640): java.lang.RuntimeException: Unable to create service com.pfe.MonService: java.lang.IllegalArgumentException: provider=network
02-21 14:05:40.571: E/AndroidRuntime(640): at android.app.ActivityThread.handleCreateService(ActivityThread.java:2262)
02-21 14:05:40.571: E/AndroidRuntime(640): at android.app.ActivityThread.access$1600(ActivityThread.java:122)
02-21 14:05:40.571: E/AndroidRuntime(640): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1200)
02-21 14:05:40.571: E/AndroidRuntime(640): at android.os.Handler.dispatchMessage(Handler.java:99)
02-21 14:05:40.571: E/AndroidRuntime(640): at android.os.Looper.loop(Looper.java:137)
02-21 14:05:40.571: E/AndroidRuntime(640): at android.app.ActivityThread.main(ActivityThread.java:4340)
02-21 14:05:40.571: E/AndroidRuntime(640): at java.lang.reflect.Method.invokeNative(Native Method)
02-21 14:05:40.571: E/AndroidRuntime(640): at java.lang.reflect.Method.invoke(Method.java:511)
02-21 14:05:40.571: E/AndroidRuntime(640): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
02-21 14:05:40.571: E/AndroidRuntime(640): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
02-21 14:05:40.571: E/AndroidRuntime(640): at dalvik.system.NativeStart.main(Native Method)
02-21 14:05:40.571: E/AndroidRuntime(640): Caused by: java.lang.IllegalArgumentException: provider=network
02-21 14:05:40.571: E/AndroidRuntime(640): at android.os.Parcel.readException(Parcel.java:1331)
02-21 14:05:40.571: E/AndroidRuntime(640): at android.os.Parcel.readException(Parcel.java:1281)
02-21 14:05:40.571: E/AndroidRuntime(640): at android.location.ILocationManager$Stub$Proxy.requestLocationUpdates(ILocationManager.java:646)
02-21 14:05:40.571: E/AndroidRuntime(640): at android.location.LocationManager._requestLocationUpdates(LocationManager.java:582)
02-21 14:05:40.571: E/AndroidRuntime(640): at android.location.LocationManager.requestLocationUpdates(LocationManager.java:446)
02-21 14:05:40.571: E/AndroidRuntime(640): at com.pfe.MonService.onCreate(MonService.java:58)
02-21 14:05:40.571: E/AndroidRuntime(640): at android.app.ActivityThread.handleCreateService(ActivityThread.java:2252)
02-21 14:05:40.571: E/AndroidRuntime(640): ... 10 more
You try to execute network call on main (UI) thread. This is not acceptable, because UI should be responsive and network calls are long in most cases. What you need is to run your code on the other thread using Thread class or AsyncTask. Also, you can check out this question for some details.

ListPreference is throwing a strange null pointer exception

I have an app that obtains a list of available Calendars and displays
them in the Spinner.
I have checks to ensure that if the available Calendar list is empty,
then ListPreference will still display "None available" in the Spinner.
I am using the ListPreference to display the Spinner in the
Preferences tab.
Here is the preferences.xml:
<ListPreference android:title="Calendar"
android:key="calendars"
android:summary="Calendars to use for saving Appts"
android:selectable="true"
android:entryValues="#array/cal_entryvalues_list_preference"
android:entries="#array/cal_entries_list_preference"
android:defaultValue="0"
android:enabled="true"></ListPreference>
My users have reported the following error:
java.lang.NullPointerException
at
android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:
355)
at android.widget.ArrayAdapter.getView(ArrayAdapter.java:323)
at android.widget.AbsListView.obtainView(AbsListView.java:1294)
at android.widget.ListView.measureHeightOfChildren(ListView.java:1198)
at android.widget.ListView.onMeasure(ListView.java:1109)
at android.view.View.measure(View.java:8171)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3132)
at
android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:
1012)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:381)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:304)
at android.view.View.measure(View.java:8171)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3132)
at
android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:
1012)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:381)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:304)
at
com.android.internal.widget.WeightedLinearLayout.onMeasure(WeightedLinearLayout.java:
60)
at android.view.View.measure(View.java:8171)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3132)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:245)
at android.view.View.measure(View.java:8171)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3132)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:245)
at android.view.View.measure(View.java:8171)
at android.view.ViewRoot.performTraversals(ViewRoot.java:801)
at android.view.ViewRoot.handleMessage(ViewRoot.java:1727)
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)
The stack trace seems to be pointed all internal workings of Android.
There is no reference to any of my code. This is happening on
Android 2.1 as well as Android 2.2 platforms.
Unfortunately, I have not been able to reproduce the error on my Moto
Droid. It appears from Developer Console logs that this is specific to
certain phones (e.g: HTC Incredible).
Any idea what is going on here?

Is there anyone of troubleshooting or dealing with stack overflow errors when the trace shows nothing?

Got a trace like this:
java.lang.StackOverflowError
at android.widget.TextView.onMeasure(TextView.java:5160)
at android.view.View.measure(View.java:8172)
at android.widget.TableRow.getColumnsWidths(TableRow.java:308)
at android.widget.TableLayout.findLargestCells(TableLayout.java:497)
at android.widget.TableLayout.measureVertical(TableLayout.java:462)
at android.widget.TableLayout.onMeasure(TableLayout.java:428)
at android.view.View.measure(View.java:8172)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3140)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1012)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:381)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:304)
at android.view.View.measure(View.java:8172)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3140)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1012)
at android.widget.LinearLayout.measureHorizontal(LinearLayout.java:696)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:306)
at android.view.View.measure(View.java:8172)
at android.widget.ListView.measureScrapChild(ListView.java:1135)
at android.widget.ListView.measureHeightOfChildren(ListView.java:1200)
at android.widget.ListView.onMeasure(ListView.java:1109)
at android.view.View.measure(View.java:8172)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3140)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1012)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:381)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:304)
at android.view.View.measure(View.java:8172)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3140)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:245)
at android.view.View.measure(View.java:8172)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:526)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:304)
at android.view.View.measure(View.java:8172)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3140)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:245)
at android.view.View.measure(View.java:8172)
at android.view.ViewRoot.performTraversals(ViewRoot.java:805)
at android.view.ViewRoot.handleMessage(ViewRoot.java:1744)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:144)
at android.app.ActivityThread.main(ActivityThread.java:4937)
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)
Is there anything that can be done here?
I'm getting reports of blank screens and force closes.
When stack traces don't help the best thing you can do is trace it.
Start to scatter log messages through strategic parts of your application, and once you find where it is set some breakpoints and step through.
Log.d("MyActivity", "MyClass.getView() — Initializing ");
Once you have your logs setup use LogCat

Categories

Resources