Binary XML file line #2: Error inflating class android.widget

04-18 06:58:24.808: E/AndroidRuntime(1556): FATAL EXCEPTION: main
04-18 06:58:24.808: E/AndroidRuntime(1556): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.DigitalConsultant.Prototype/com.DigitalConsultant.Prototype.MainActivity}: android.view.InflateException: Binary XML file line #2: Error inflating class android.widget.RelativeLayout
04-18 06:58:24.808: E/AndroidRuntime(1556): 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
04-18 06:58:24.808: E/AndroidRuntime(1556): 	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
04-18 06:58:24.808: E/AndroidRuntime(1556): 	at android.app.ActivityThread.access$600(ActivityThread.java:130)
04-18 06:58:24.808: E/AndroidRuntime(1556): 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
04-18 06:58:24.808: E/AndroidRuntime(1556): 	at android.os.Handler.dispatchMessage(Handler.java:99)
04-18 06:58:24.808: E/AndroidRuntime(1556): 	at android.os.Looper.loop(Looper.java:137)
04-18 06:58:24.808: E/AndroidRuntime(1556): 	at android.app.ActivityThread.main(ActivityThread.java:4745)
04-18 06:58:24.808: E/AndroidRuntime(1556): 	at java.lang.reflect.Method.invokeNative(Native Method)
04-18 06:58:24.808: E/AndroidRuntime(1556): 	at java.lang.reflect.Method.invoke(Method.java:511)
04-18 06:58:24.808: E/AndroidRuntime(1556): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
04-18 06:58:24.808: E/AndroidRuntime(1556): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
04-18 06:58:24.808: E/AndroidRuntime(1556): 	at dalvik.system.NativeStart.main(Native Method)
04-18 06:58:24.808: E/AndroidRuntime(1556): Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class android.widget.RelativeLayout
04-18 06:58:24.808: E/AndroidRuntime(1556): 	at android.view.LayoutInflater.createView(LayoutInflater.java:613)
04-18 06:58:24.808: E/AndroidRuntime(1556): 	at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
04-18 06:58:24.808: E/AndroidRuntime(1556): 	at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660)
04-18 06:58:24.808: E/AndroidRuntime(1556): 	at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
04-18 06:58:24.808: E/AndroidRuntime(1556): 	at android.view.LayoutInflater.inflate(LayoutInflater.java:466)
04-18 06:58:24.808: E/AndroidRuntime(1556): 	at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
04-18 06:58:24.808: E/AndroidRuntime(1556): 	at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
04-18 06:58:24.808: E/AndroidRuntime(1556): 	at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:256)
04-18 06:58:24.808: E/AndroidRuntime(1556): 	at android.app.Activity.setContentView(Activity.java:1867)
04-18 06:58:24.808: E/AndroidRuntime(1556): 	at com.DigitalConsultant.Prototype.MainActivity.onCreate(MainActivity.java:11)
04-18 06:58:24.808: E/AndroidRuntime(1556): 	at android.app.Activity.performCreate(Activity.java:5008)
04-18 06:58:24.808: E/AndroidRuntime(1556): 	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
04-18 06:58:24.808: E/AndroidRuntime(1556): 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
04-18 06:58:24.808: E/AndroidRuntime(1556): 	... 11 more
04-18 06:58:24.808: E/AndroidRuntime(1556): Caused by: java.lang.reflect.InvocationTargetException
04-18 06:58:24.808: E/AndroidRuntime(1556): 	at java.lang.reflect.Constructor.constructNative(Native Method)
04-18 06:58:24.808: E/AndroidRuntime(1556): 	at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
04-18 06:58:24.808: E/AndroidRuntime(1556): 	at android.view.LayoutInflater.createView(LayoutInflater.java:587)
04-18 06:58:24.808: E/AndroidRuntime(1556): 	... 23 more
04-18 06:58:24.808: E/AndroidRuntime(1556): Caused by: java.lang.OutOfMemoryError
04-18 06:58:24.808: E/AndroidRuntime(1556): 	at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
04-18 06:58:24.808: E/AndroidRuntime(1556): 	at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:500)
04-18 06:58:24.808: E/AndroidRuntime(1556): 	at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:353)
04-18 06:58:24.808: E/AndroidRuntime(1556): 	at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:781)
04-18 06:58:24.808: E/AndroidRuntime(1556): 	at android.content.res.Resources.loadDrawable(Resources.java:1930)
04-18 06:58:24.808: E/AndroidRuntime(1556): 	at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
04-18 06:58:24.808: E/AndroidRuntime(1556): 	at android.view.View.(View.java:3336)
04-18 06:58:24.808: E/AndroidRuntime(1556): 	at android.view.View.(View.java:3273)
04-18 06:58:24.808: E/AndroidRuntime(1556): 	at android.view.ViewGroup.(ViewGroup.java:421)
04-18 06:58:24.808: E/AndroidRuntime(1556): 	at android.widget.RelativeLayout.(RelativeLayout.java:184)
04-18 06:58:24.808: E/AndroidRuntime(1556): 	... 26 more


这个问题是因为找不到资源文件导致,在机器对应的drawable文件夹下加入这些资源文件。

或者在res下建立一个drawable文件夹来存放这些文件。

应该是程序自适应手机的问题,我的思路就是这样,问题就解决了~

你可能感兴趣的:(Android开发)