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?
Related
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.
I am working on Mapview.I am getting error but i have no idea why i can getting this.I debug all of the item .I didnt see it before.
Can anybody see this error?I now it is null exception but can anybody see PixelConverter?
ERROR/AndroidRuntime(1382): FATAL EXCEPTION: main
java.lang.NullPointerException
at com.google.android.maps.PixelConverter.toPixels(PixelConverter.java:71)
at com.google.android.maps.PixelConverter.toPixels(PixelConverter.java:61)
at com.google.android.maps.MapView.onLayout(MapView.java:681)
at android.view.View.layout(View.java:7035)
at android.widget.RelativeLayout.onLayout(RelativeLayout.java:909)
at android.view.View.layout(View.java:7035)
at android.widget.FrameLayout.onLayout(FrameLayout.java:333)
at android.view.View.layout(View.java:7035)
at android.widget.FrameLayout.onLayout(FrameLayout.java:333)
at android.view.View.layout(View.java:7035)
at android.view.ViewRoot.performTraversals(ViewRoot.java:1045)
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)
There is an error in my Android application that happens quite often, based on the crash report on the Developer Console.
java.lang.NullPointerException
at android.widget.AbsListView.obtainView(AbsListView.java:1304)
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.FrameLayout.onMeasure(FrameLayout.java:245)
at android.view.View.measure(View.java:8171)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:526)
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.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:878)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:636)
at dalvik.system.NativeStart.main(Native Method)
Unfortunately, I can't replicate that error on my Android phone.
I dont' know where to start: in the trace there isn't any reference to my code.
Can somebody give me some suggestions on how to identify the root of the problem, please?
Thanks,
Dan
The most obvious things I can think of:
AbsListView.obtainView() I believe is communicating with the Adopter to populate the list view. Make sure there is never a case where you could return a null back to the list view.
There may be a bug in some version of the platform. Unfortunately the developer console does not currently show you the platform version the error reports came from. Hopefully this will be added in the future to help diagnose such a situation.
It is possible someone is running a non-standard or custom build of the platform that has bugs. You might be able to determine this by looking at the "platforms" section for the different devices the error is coming from.
I would try creating a virtual device and load it in the emulator, start with the smallest resolution.
I am suspecting that it has to do with screen size and somehow you are trying to draw in a pixel that doesn't exist.
I'm trying to run a sub process on Android (see this question) which requires that the PYTHONHOME environment variable be set. I tried to do so with the following code:
ProcessBuilder pbuilder = new ProcessBuilder("python/bin/python", "test.py");
pbuilder.directory(getFilesDir());
Map<String, String> env = pbuilder.environment();
env.put("PYTHONHOME", "python");
Process process = pbuilder.start();
but I get this exception:
E/AndroidRuntime(25857): FATAL EXCEPTION: main
E/AndroidRuntime(25857): java.lang.UnsupportedOperationException: Can't modify environment
E/AndroidRuntime(25857): at java.lang.SystemEnvironment.put(System.java:740)
E/AndroidRuntime(25857): at java.lang.SystemEnvironment.put(System.java:688)
E/AndroidRuntime(25857): at my code
E/AndroidRuntime(25857): at android.view.View.performClick(View.java:2408)
E/AndroidRuntime(25857): at android.view.View$PerformClick.run(View.java:8816)
E/AndroidRuntime(25857): at android.os.Handler.handleCallback(Handler.java:587)
E/AndroidRuntime(25857): at android.os.Handler.dispatchMessage(Handler.java:92)
E/AndroidRuntime(25857): at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime(25857): at android.app.ActivityThread.main(ActivityThread.java:4627)
E/AndroidRuntime(25857): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(25857): at java.lang.reflect.Method.invoke(Method.java:521)
E/AndroidRuntime(25857): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
E/AndroidRuntime(25857): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
E/AndroidRuntime(25857): at dalvik.system.NativeStart.main(Native Method)
Does anyone have any advice? I've tried wrapping the call to python in a shell script which exports PYTHONHOME but that didn't do the trick.
Gabe
Just recently ran into the same problem. Seems like you can't modify the ProcessBuilder's environment map on Android versions <= 2.2. The only workaround that I found was to use exec() rather than the ProcessBuilder. In your case, this would result in something along the lines of:
String[] cmdarray = {"python/bin/python", "test.py"};
String[] envp = {"PYTHONHOME=python"};
Process process = Runtime.getRuntime().exec(cmdarray, envp, getFilesDir());
Hope that helps.
C
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