Lance, Thanks for your reply.

Finally I could track down the problem. "<PreferenceCategory>" was the root of 
the issue! For whatever reason, that exception occurs when I build against v1.6 
and run it under v1.5 or when I build it against v1.5 and run it under v1.6... 
The problem vanishes when I remove my PreferenceCategory's from 
"preferences.xml".

Can you reproduce this with your code?

As for the cause, when I tracked it even further, I found out that when a 
<PreferencesCategory> is inflated using the default layout, it's using  
"preference_category.xml" layout from platform (you can find it under 
"<ANDROID_SDK_HOME>/platforms/android-1.x/data/res/layout"). You'll find the 
following block inside the file (both for v1.5 and v1.6):

<TextView xmlns:android="http://schemas.android.com/apk/res/android";
    style="?android:attr/listSeparatorTextViewStyle"
    android:id="@+android:id/title"
/>

And obviously it includes neither "layout_height" not "layout_width" attribute! 
As a solution (maybe temporary!), I copied this file to my project's "layout/" 
directory and added the above missing parameters to it. And in my 
"preferences.xml" I assigned android:layout="@layout/preference_category" 
attribute to all of the <PreferenceCategory> tags. The problem resolved!!!

But I'm still in wonder with such missing parameter, why it works flawlessly 
when I build and run the project under the same Android version??

Best Regards,
Armond




----- Original Message ----
> From: Lance Nanek <lna...@gmail.com>
> To: Android Developers <android-developers@googlegroups.com>
> Sent: Wed, November 4, 2009 3:44:20 AM
> Subject: [android-developers] Re: Problem running a 
> compiled/packaged-with-v1.6  application on v1.5
> 
> Hmm, I have an app that similarly uses a PreferenceActivity and build
> target 1.6, but it runs fine on the 1.5 emulator. I wonder what we are
> doing different.
> 
> Is your activity just the basic form like this?
> public class Preferences extends PreferenceActivity {
>     @Override
>     protected void onCreate(Bundle savedInstanceState) {
>         super.onCreate(savedInstanceState);
>         addPreferencesFromResource(R.xml.preferences);
>     }
> }
> 
> Are you calling Preference#setLayoutResource in any way? Seems like
> that could change the XML file being used. I think I found the default
> one in the Android source, but don't see the missing attribute in it.
> 
> On Nov 3, 5:03 pm, "Armond Avanes" wrote:
> > Hi Guys,
> >
> > I have an application which is based Android 1.5 but for enabling different
> > screen types support I have to compile and package it with v1.6. When I
> > install and run the resulted APK on my 1.5 emulator, everything works fine
> > except that "Preferences" activity crashes every time I launch it!
> >
> > When I revert back my API dependency to 1.5 and remove a few 1.6 specific
> > config blocks from AndroidManifest.xml and compile/package it with 1.5,
> > everything works just fine!!
> >
> > Below is the exception I get when it crashes. I will highly appreciate any
> > help on this:
> >
> > D/AndroidRuntime(  985): Shutting down VM
> > W/dalvikvm(  985): threadid=3: thread exiting with uncaught exception
> > (group=0x4000fe70)
> > E/AndroidRuntime(  985): Uncaught handler: thread main exiting due to
> > uncaught exception
> > E/AndroidRuntime(  985): java.lang.RuntimeException: Binary XML file line
> > #18: You must supply a layout_width attribute.
> > E/AndroidRuntime(  985):        at
> > android.content.res.TypedArray.getLayoutDimension(TypedArray.java:438)
> > E/AndroidRuntime(  985):        at
> > android.view.ViewGroup$LayoutParams.setBaseAttributes(ViewGroup.java:3319)
> > E/AndroidRuntime(  985):        at
> > android.view.ViewGroup$LayoutParams.(ViewGroup.java:3274)
> > E/AndroidRuntime(  985):        at
> > android.widget.AbsListView$LayoutParams.(AbsListView.java:3242)
> > E/AndroidRuntime(  985):        at
> > android.widget.AbsListView.generateLayoutParams(AbsListView.java:3123)
> > E/AndroidRuntime(  985):        at
> > android.widget.AbsListView.generateLayoutParams(AbsListView.java:69)
> > E/AndroidRuntime(  985):        at
> > android.view.LayoutInflater.inflate(LayoutInflater.java:395)
> > E/AndroidRuntime(  985):        at
> > android.view.LayoutInflater.inflate(LayoutInflater.java:320)
> > E/AndroidRuntime(  985):        at
> > android.preference.Preference.onCreateView(Preference.java:412)
> > E/AndroidRuntime(  985):        at
> > android.preference.Preference.getView(Preference.java:389)
> > E/AndroidRuntime(  985):        at
> > android.preference.PreferenceGroupAdapter.getView(PreferenceGroupAdapter.jav
> > a:187)
> > E/AndroidRuntime(  985):        at
> > android.widget.AbsListView.obtainView(AbsListView.java:1269)
> > E/AndroidRuntime(  985):        at
> > android.widget.ListView.makeAndAddView(ListView.java:1623)
> > E/AndroidRuntime(  985):        at
> > android.widget.ListView.fillDown(ListView.java:607)
> > E/AndroidRuntime(  985):        at
> > android.widget.ListView.fillFromTop(ListView.java:664)
> > E/AndroidRuntime(  985):        at
> > android.widget.ListView.layoutChildren(ListView.java:1481)
> > E/AndroidRuntime(  985):        at
> > android.widget.AbsListView.onLayout(AbsListView.java:1113)
> > E/AndroidRuntime(  985):        at android.view.View.layout(View.java:6133)
> > E/AndroidRuntime(  985):        at
> > android.widget.FrameLayout.onLayout(FrameLayout.java:333)
> > E/AndroidRuntime(  985):        at android.view.View.layout(View.java:6133)
> > E/AndroidRuntime(  985):        at
> > android.widget.LinearLayout.setChildFrame(LinearLayout.java:1119)
> > E/AndroidRuntime(  985):        at
> > android.widget.LinearLayout.layoutVertical(LinearLayout.java:998)
> > E/AndroidRuntime(  985):        at
> > android.widget.LinearLayout.onLayout(LinearLayout.java:918)
> > E/AndroidRuntime(  985):        at android.view.View.layout(View.java:6133)
> > E/AndroidRuntime(  985):        at
> > android.widget.FrameLayout.onLayout(FrameLayout.java:333)
> > E/AndroidRuntime(  985):        at android.view.View.layout(View.java:6133)
> > E/AndroidRuntime(  985):        at
> > android.view.ViewRoot.performTraversals(ViewRoot.java:929)
> > E/AndroidRuntime(  985):        at
> > android.view.ViewRoot.handleMessage(ViewRoot.java:1482)
> > E/AndroidRuntime(  985):        at
> > android.os.Handler.dispatchMessage(Handler.java:99)
> > E/AndroidRuntime(  985):        at android.os.Looper.loop(Looper.java:123)
> > E/AndroidRuntime(  985):        at
> > android.app.ActivityThread.main(ActivityThread.java:3948)
> > E/AndroidRuntime(  985):        at
> > java.lang.reflect.Method.invokeNative(Native Method)
> > E/AndroidRuntime(  985):        at
> > java.lang.reflect.Method.invoke(Method.java:521)
> > E/AndroidRuntime(  985):        at
> > com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:7
> > 82)
> > E/AndroidRuntime(  985):        at
> > com.android.internal.os.ZygoteInit.main(ZygoteInit.java:540)
> > E/AndroidRuntime(  985):        at dalvik.system.NativeStart.main(Native
> > Method)
> >
> > Best Regards,
> > Armond
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to