这是我所做的:
- 创建新的安卓项目
- 添加了 ActionBarSherlock
- 添加了操作栏颜色生成器文件
- 经过测试的应用程序 - 使用我的操作栏颜色在 2.x 和 4.x 上运行
- 通过全息颜色生成器创建文件
- 向项目添加了全息颜色生成器文件
- 没有改变主题或任何东西。到目前为止,应用程序应该仍然可以运行,因为我没有更改清单或样式中的任何主题。
- 测试应用程序 - 尝试在 2.x 和 4.x 上运行,但每次都崩溃
如果我从未设置新样式/主题,我不明白应用程序如何崩溃。
我在每个设备版本上都会遇到同样的崩溃。
日志猫:
07-23 23:32:31.942: E/AndroidRuntime(13026): FATAL EXCEPTION: main
07-23 23:32:31.942: E/AndroidRuntime(13026): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.whatthe/com.example.whatthe.MainActivity}: android.view.InflateException: Binary XML file line #1: Error inflating class android.widget.RelativeLayout
07-23 23:32:31.942: E/AndroidRuntime(13026): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
07-23 23:32:31.942: E/AndroidRuntime(13026): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
07-23 23:32:31.942: E/AndroidRuntime(13026): at android.app.ActivityThread.access$600(ActivityThread.java:141)
07-23 23:32:31.942: E/AndroidRuntime(13026): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
07-23 23:32:31.942: E/AndroidRuntime(13026): at android.os.Handler.dispatchMessage(Handler.java:99)
07-23 23:32:31.942: E/AndroidRuntime(13026): at android.os.Looper.loop(Looper.java:137)
07-23 23:32:31.942: E/AndroidRuntime(13026): at android.app.ActivityThread.main(ActivityThread.java:5041)
07-23 23:32:31.942: E/AndroidRuntime(13026): at java.lang.reflect.Method.invokeNative(Native Method)
07-23 23:32:31.942: E/AndroidRuntime(13026): at java.lang.reflect.Method.invoke(Method.java:511)
07-23 23:32:31.942: E/AndroidRuntime(13026): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
07-23 23:32:31.942: E/AndroidRuntime(13026): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
07-23 23:32:31.942: E/AndroidRuntime(13026): at dalvik.system.NativeStart.main(Native Method)
07-23 23:32:31.942: E/AndroidRuntime(13026): Caused by: android.view.InflateException: Binary XML file line #1: Error inflating class android.widget.RelativeLayout
07-23 23:32:31.942: E/AndroidRuntime(13026): at android.view.LayoutInflater.createView(LayoutInflater.java:613)
07-23 23:32:31.942: E/AndroidRuntime(13026): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
07-23 23:32:31.942: E/AndroidRuntime(13026): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660)
07-23 23:32:31.942: E/AndroidRuntime(13026): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
07-23 23:32:31.942: E/AndroidRuntime(13026): at android.view.LayoutInflater.inflate(LayoutInflater.java:466)
07-23 23:32:31.942: E/AndroidRuntime(13026): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
07-23 23:32:31.942: E/AndroidRuntime(13026): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
07-23 23:32:31.942: E/AndroidRuntime(13026): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:270)
07-23 23:32:31.942: E/AndroidRuntime(13026): at com.actionbarsherlock.internal.ActionBarSherlockNative.setContentView(ActionBarSherlockNative.java:134)
07-23 23:32:31.942: E/AndroidRuntime(13026): at com.actionbarsherlock.app.SherlockActivity.setContentView(SherlockActivity.java:229)
07-23 23:32:31.942: E/AndroidRuntime(13026): at com.example.whatthe.MainActivity.onCreate(MainActivity.java:14)
07-23 23:32:31.942: E/AndroidRuntime(13026): at android.app.Activity.performCreate(Activity.java:5104)
07-23 23:32:31.942: E/AndroidRuntime(13026): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
07-23 23:32:31.942: E/AndroidRuntime(13026): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
07-23 23:32:31.942: E/AndroidRuntime(13026): ... 11 more
07-23 23:32:31.942: E/AndroidRuntime(13026): Caused by: java.lang.reflect.InvocationTargetException
07-23 23:32:31.942: E/AndroidRuntime(13026): at java.lang.reflect.Constructor.constructNative(Native Method)
07-23 23:32:31.942: E/AndroidRuntime(13026): at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
07-23 23:32:31.942: E/AndroidRuntime(13026): at android.view.LayoutInflater.createView(LayoutInflater.java:587)
07-23 23:32:31.942: E/AndroidRuntime(13026): ... 24 more
07-23 23:32:31.942: E/AndroidRuntime(13026): Caused by: java.lang.UnsupportedOperationException: Can't convert to dimension: type=0x1
07-23 23:32:31.942: E/AndroidRuntime(13026): at android.content.res.TypedArray.getDimensionPixelSize(TypedArray.java:463)
07-23 23:32:31.942: E/AndroidRuntime(13026): at android.view.View.<init>(View.java:3340)
07-23 23:32:31.942: E/AndroidRuntime(13026): at android.view.View.<init>(View.java:3259)
07-23 23:32:31.942: E/AndroidRuntime(13026): at android.view.ViewGroup.<init>(ViewGroup.java:425)
07-23 23:32:31.942: E/AndroidRuntime(13026): at android.widget.RelativeLayout.<init>(RelativeLayout.java:210)
07-23 23:32:31.942: E/AndroidRuntime(13026): ... 27 more
编辑#1
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
tools:context=".MainActivity" >
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView2"
android:layout_below="@+id/textView2"
android:text="TextView" />
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView1"
android:layout_below="@+id/textView1"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView3"
android:layout_below="@+id/textView3"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView4"
android:layout_below="@+id/textView4"
android:text="Small Text"
android:textAppearance="?android:attr/textAppearanceSmall" />
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignTop="@+id/textView2"
android:text="Button" />
<Button
android:id="@+id/button2"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/textView4"
android:layout_alignBottom="@+id/textView4"
android:layout_alignLeft="@+id/button1"
android:text="Button" />
<ToggleButton
android:id="@+id/toggleButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="@+id/button2"
android:layout_below="@+id/textView5"
android:text="ToggleButton" />
<RadioButton
android:id="@+id/radioButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView5"
android:layout_alignTop="@+id/toggleButton1"
android:text="RadioButton" />
<CheckBox
android:id="@+id/checkBox1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/radioButton1"
android:layout_below="@+id/radioButton1"
android:text="CheckBox" />
<CheckedTextView
android:id="@+id/checkedTextView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/checkBox1"
android:layout_below="@+id/checkBox1"
android:text="CheckedTextView" />
<ProgressBar
android:id="@+id/progressBar1"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="@+id/toggleButton1"
android:layout_below="@+id/toggleButton1" />
<SeekBar
android:id="@+id/seekBar1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/progressBar2" />
<RatingBar
android:id="@+id/ratingBar1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/seekBar1"
android:layout_below="@+id/seekBar1" />
<Spinner
android:id="@+id/spinner1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/ratingBar1"
android:layout_below="@+id/ratingBar1" />
<ProgressBar
android:id="@+id/progressBar2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/checkedTextView1"
android:layout_centerVertical="true" />
</RelativeLayout>