我为apiMin 11创建了我的应用程序。 现在我想将minSDK设置为8,所以我在Manifest中更改它并添加构建路径表单android-support-v4。我首先使用API 18测试它。 之后我尝试使用API 8在设备上运行。现在我遇到了很多错误,但不知道如何解决它。
04-30 11:06:16.734: E/AndroidRuntime(338): FATAL EXCEPTION: main
04-30 11:06:16.734: E/AndroidRuntime(338): java.lang.RuntimeException: Unable to start activity ComponentInfo{de.basti12354.bikinifigur2/de.basti12354.bikinifigur2.MainActivity}: android.view.InflateException: Binary XML file line #18: Error inflating class android.widget.ImageButton
04-30 11:06:16.734: E/AndroidRuntime(338): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
04-30 11:06:16.734: E/AndroidRuntime(338): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
04-30 11:06:16.734: E/AndroidRuntime(338): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
04-30 11:06:16.734: E/AndroidRuntime(338): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
04-30 11:06:16.734: E/AndroidRuntime(338): at android.os.Handler.dispatchMessage(Handler.java:99)
04-30 11:06:16.734: E/AndroidRuntime(338): at android.os.Looper.loop(Looper.java:123)
04-30 11:06:16.734: E/AndroidRuntime(338): at android.app.ActivityThread.main(ActivityThread.java:3683)
04-30 11:06:16.734: E/AndroidRuntime(338): at java.lang.reflect.Method.invokeNative(Native Method)
04-30 11:06:16.734: E/AndroidRuntime(338): at java.lang.reflect.Method.invoke(Method.java:507)
04-30 11:06:16.734: E/AndroidRuntime(338): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
04-30 11:06:16.734: E/AndroidRuntime(338): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
04-30 11:06:16.734: E/AndroidRuntime(338): at dalvik.system.NativeStart.main(Native Method)
04-30 11:06:16.734: E/AndroidRuntime(338): Caused by: android.view.InflateException: Binary XML file line #18: Error inflating class android.widget.ImageButton
04-30 11:06:16.734: E/AndroidRuntime(338): at android.view.LayoutInflater.createView(LayoutInflater.java:518)
04-30 11:06:16.734: E/AndroidRuntime(338): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
04-30 11:06:16.734: E/AndroidRuntime(338): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:568)
04-30 11:06:16.734: E/AndroidRuntime(338): at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)
04-30 11:06:16.734: E/AndroidRuntime(338): at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
04-30 11:06:16.734: E/AndroidRuntime(338): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
04-30 11:06:16.734: E/AndroidRuntime(338): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
04-30 11:06:16.734: E/AndroidRuntime(338): at android.support.v7.app.ActionBarActivityDelegateBase.setContentView(ActionBarActivityDelegateBase.java:138)
04-30 11:06:16.734: E/AndroidRuntime(338): at android.support.v7.app.ActionBarActivity.setContentView(ActionBarActivity.java:76)
04-30 11:06:16.734: E/AndroidRuntime(338): at de.basti12354.bikinifigur2.MainActivity.onCreate(MainActivity.java:33)
04-30 11:06:16.734: E/AndroidRuntime(338): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
04-30 11:06:16.734: E/AndroidRuntime(338): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
04-30 11:06:16.734: E/AndroidRuntime(338): ... 11 more
04-30 11:06:16.734: E/AndroidRuntime(338): Caused by: java.lang.reflect.InvocationTargetException
04-30 11:06:16.734: E/AndroidRuntime(338): at java.lang.reflect.Constructor.constructNative(Native Method)
04-30 11:06:16.734: E/AndroidRuntime(338): at java.lang.reflect.Constructor.newInstance(Constructor.java:415)
04-30 11:06:16.734: E/AndroidRuntime(338): at android.view.LayoutInflater.createView(LayoutInflater.java:505)
04-30 11:06:16.734: E/AndroidRuntime(338): ... 22 more
04-30 11:06:16.734: E/AndroidRuntime(338): Caused by: android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x2/d=0x101030e a=-1}
04-30 11:06:16.734: E/AndroidRuntime(338): at android.content.res.Resources.loadDrawable(Resources.java:1681)
04-30 11:06:16.734: E/AndroidRuntime(338): at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
04-30 11:06:16.734: E/AndroidRuntime(338): at android.view.View.<init>(View.java:1951)
04-30 11:06:16.734: E/AndroidRuntime(338): at android.widget.ImageView.<init>(ImageView.java:112)
04-30 11:06:16.734: E/AndroidRuntime(338): at android.widget.ImageButton.<init>(ImageButton.java:85)
04-30 11:06:16.734: E/AndroidRuntime(338): at android.widget.ImageButton.<init>(ImageButton.java:81)
04-30 11:06:16.734: E/AndroidRuntime(338): ... 25 more
这是xml文件:错误是使用android:background="?android:selectableItemBackground"
<ImageButton
android:id="@+id/impressum"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="?android:selectableItemBackground"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:src="@drawable/impressum" />
还有其他解决办法来解决这个问题:android:background="?android:selectableItemBackground"