在文件夹 res/drawable/ 我已经存储了我的图像 pic.jpg,但是当我在我的设备上运行它时,应用程序强制关闭。android项目是自动生成的,除了我将包含所有内容的RelativeLayout更改为LinearLayout。在此 LinearLayout 中,我只编写了一个 ImageView。应用程序力关闭而不显示任何内容。请问,我做错了什么?
相关的 XML:
<ImageView
android:layout_width="85dp"
android:layout_height="85dp"
android:src="@+drawable/pic"
android:contentDescription="@string/none"
/>
这是日志猫:
03-13 12:56:54.920: E/AndroidRuntime(21033): FATAL EXCEPTION: main
03-13 12:56:54.920: E/AndroidRuntime(21033): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.imageshow/com.example.imageshow.MainActivity}: android.view.InflateException: Binary XML file line #17: Error inflating class android.widget.ImageView
03-13 12:56:54.920: E/AndroidRuntime(21033): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1651)
03-13 12:56:54.920: E/AndroidRuntime(21033): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
03-13 12:56:54.920: E/AndroidRuntime(21033): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
03-13 12:56:54.920: E/AndroidRuntime(21033): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
03-13 12:56:54.920: E/AndroidRuntime(21033): at android.os.Handler.dispatchMessage(Handler.java:99)
03-13 12:56:54.920: E/AndroidRuntime(21033): at android.os.Looper.loop(Looper.java:130)
03-13 12:56:54.920: E/AndroidRuntime(21033): at android.app.ActivityThread.main(ActivityThread.java:3691)
03-13 12:56:54.920: E/AndroidRuntime(21033): at java.lang.reflect.Method.invokeNative(Native Method)
03-13 12:56:54.920: E/AndroidRuntime(21033): at java.lang.reflect.Method.invoke(Method.java:507)
03-13 12:56:54.920: E/AndroidRuntime(21033): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:907)
03-13 12:56:54.920: E/AndroidRuntime(21033): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:665)
03-13 12:56:54.920: E/AndroidRuntime(21033): at dalvik.system.NativeStart.main(Native Method)
03-13 12:56:54.920: E/AndroidRuntime(21033): Caused by: android.view.InflateException: Binary XML file line #17: Error inflating class android.widget.ImageView
03-13 12:56:54.920: E/AndroidRuntime(21033): at android.view.LayoutInflater.createView(LayoutInflater.java:518)
03-13 12:56:54.920: E/AndroidRuntime(21033): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
03-13 12:56:54.920: E/AndroidRuntime(21033): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:568)
03-13 12:56:54.920: E/AndroidRuntime(21033): at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)
03-13 12:56:54.920: E/AndroidRuntime(21033): at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
03-13 12:56:54.920: E/AndroidRuntime(21033): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
03-13 12:56:54.920: E/AndroidRuntime(21033): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
03-13 12:56:54.920: E/AndroidRuntime(21033): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:215)
03-13 12:56:54.920: E/AndroidRuntime(21033): at android.app.Activity.setContentView(Activity.java:1679)
03-13 12:56:54.920: E/AndroidRuntime(21033): at com.example.imageshow.MainActivity.onCreate(MainActivity.java:12)
03-13 12:56:54.920: E/AndroidRuntime(21033): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
03-13 12:56:54.920: E/AndroidRuntime(21033): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615)
03-13 12:56:54.920: E/AndroidRuntime(21033): ... 11 more
03-13 12:56:54.920: E/AndroidRuntime(21033): Caused by: java.lang.reflect.InvocationTargetException
03-13 12:56:54.920: E/AndroidRuntime(21033): at java.lang.reflect.Constructor.constructNative(Native Method)
03-13 12:56:54.920: E/AndroidRuntime(21033): at java.lang.reflect.Constructor.newInstance(Constructor.java:415)
03-13 12:56:54.920: E/AndroidRuntime(21033): at android.view.LayoutInflater.createView(LayoutInflater.java:505)
03-13 12:56:54.920: E/AndroidRuntime(21033): ... 22 more
03-13 12:56:54.920: E/AndroidRuntime(21033): Caused by: android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x12/d=0x0 a=3 r=0x7f020001}
03-13 12:56:54.920: E/AndroidRuntime(21033): at android.content.res.Resources.loadDrawable(Resources.java:1907)
03-13 12:56:54.920: E/AndroidRuntime(21033): at android.content.res.TypedArray.getDrawable(TypedArray.java:653)
03-13 12:56:54.920: E/AndroidRuntime(21033): at android.widget.ImageView.<init>(ImageView.java:118)
03-13 12:56:54.920: E/AndroidRuntime(21033): at android.widget.ImageView.<init>(ImageView.java:108)
03-13 12:56:54.920: E/AndroidRuntime(21033): ... 25 more