2011-04-27 61 views
2

我完全失去了這一個。我的應用程序可以在手機上通過API 2.1完美工作,並通過仿真器工作。 我剛剛經歷了2.2模擬器中運行它,我得到一個崩潰和這個錯誤:二進制XML文件行#2:錯誤膨脹類android.widget.LinearLayout

04-27 20:29:41.293: ERROR/AndroidRuntime(341): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.ebp/com.ebp.ebpMainMenu}: android.view.InflateException: Binary XML file line #2: Error inflating class android.widget.LinearLayout 
04-27 20:29:41.293: ERROR/AndroidRuntime(341):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2496) 
04-27 20:29:41.293: ERROR/AndroidRuntime(341):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512) 
04-27 20:29:41.293: ERROR/AndroidRuntime(341):  at android.app.ActivityThread.access$2200(ActivityThread.java:119) 
04-27 20:29:41.293: ERROR/AndroidRuntime(341):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863) 
04-27 20:29:41.293: ERROR/AndroidRuntime(341):  at android.os.Handler.dispatchMessage(Handler.java:99) 
04-27 20:29:41.293: ERROR/AndroidRuntime(341):  at android.os.Looper.loop(Looper.java:123) 
04-27 20:29:41.293: ERROR/AndroidRuntime(341):  at android.app.ActivityThread.main(ActivityThread.java:4363) 
04-27 20:29:41.293: ERROR/AndroidRuntime(341):  at java.lang.reflect.Method.invokeNative(Native Method) 
04-27 20:29:41.293: ERROR/AndroidRuntime(341):  at java.lang.reflect.Method.invoke(Method.java:521) 
04-27 20:29:41.293: ERROR/AndroidRuntime(341):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860) 
04-27 20:29:41.293: ERROR/AndroidRuntime(341):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618) 
04-27 20:29:41.293: ERROR/AndroidRuntime(341):  at dalvik.system.NativeStart.main(Native Method) 
04-27 20:29:41.293: ERROR/AndroidRuntime(341): Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class android.widget.LinearLayout 
04-27 20:29:41.293: ERROR/AndroidRuntime(341):  at android.view.LayoutInflater.createView(LayoutInflater.java:513) 
04-27 20:29:41.293: ERROR/AndroidRuntime(341):  at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56) 
04-27 20:29:41.293: ERROR/AndroidRuntime(341):  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563) 
04-27 20:29:41.293: ERROR/AndroidRuntime(341):  at android.view.LayoutInflater.inflate(LayoutInflater.java:385) 
04-27 20:29:41.293: ERROR/AndroidRuntime(341):  at android.view.LayoutInflater.inflate(LayoutInflater.java:320) 
04-27 20:29:41.293: ERROR/AndroidRuntime(341):  at android.view.LayoutInflater.inflate(LayoutInflater.java:276) 
04-27 20:29:41.293: ERROR/AndroidRuntime(341):  at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:198) 
04-27 20:29:41.293: ERROR/AndroidRuntime(341):  at android.app.Activity.setContentView(Activity.java:1622) 
04-27 20:29:41.293: ERROR/AndroidRuntime(341):  at com.ebp.ebpMainMenu.onCreate(ebpMainMenu.java:58) 
04-27 20:29:41.293: ERROR/AndroidRuntime(341):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) 
04-27 20:29:41.293: ERROR/AndroidRuntime(341):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459) 
04-27 20:29:41.293: ERROR/AndroidRuntime(341):  ... 11 more 
04-27 20:29:41.293: ERROR/AndroidRuntime(341): Caused by: java.lang.reflect.InvocationTargetException 
04-27 20:29:41.293: ERROR/AndroidRuntime(341):  at android.widget.LinearLayout.<init>(LinearLayout.java:92) 
04-27 20:29:41.293: ERROR/AndroidRuntime(341):  at java.lang.reflect.Constructor.constructNative(Native Method) 
04-27 20:29:41.293: ERROR/AndroidRuntime(341):  at java.lang.reflect.Constructor.newInstance(Constructor.java:446) 
04-27 20:29:41.293: ERROR/AndroidRuntime(341):  at android.view.LayoutInflater.createView(LayoutInflater.java:500) 
04-27 20:29:41.293: ERROR/AndroidRuntime(341):  ... 21 more 
04-27 20:29:41.293: ERROR/AndroidRuntime(341): Caused by: java.lang.OutOfMemoryError: bitmap size exceeds VM budget 
04-27 20:29:41.293: ERROR/AndroidRuntime(341):  at android.graphics.Bitmap.nativeCreate(Native Method) 
04-27 20:29:41.293: ERROR/AndroidRuntime(341):  at android.graphics.Bitmap.createBitmap(Bitmap.java:468) 
04-27 20:29:41.293: ERROR/AndroidRuntime(341):  at android.graphics.Bitmap.createBitmap(Bitmap.java:435) 
04-27 20:29:41.293: ERROR/AndroidRuntime(341):  at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:340) 
04-27 20:29:41.293: ERROR/AndroidRuntime(341):  at android.graphics.BitmapFactory.finishDecode(BitmapFactory.java:488) 
04-27 20:29:41.293: ERROR/AndroidRuntime(341):  at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:462) 
04-27 20:29:41.293: ERROR/AndroidRuntime(341):  at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:323) 
04-27 20:29:41.293: ERROR/AndroidRuntime(341):  at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:697) 
04-27 20:29:41.293: ERROR/AndroidRuntime(341):  at android.content.res.Resources.loadDrawable(Resources.java:1705) 
04-27 20:29:41.293: ERROR/AndroidRuntime(341):  at android.content.res.TypedArray.getDrawable(TypedArray.java:548) 
04-27 20:29:41.293: ERROR/AndroidRuntime(341):  at android.view.View.<init>(View.java:1850) 
04-27 20:29:41.293: ERROR/AndroidRuntime(341):  at android.view.View.<init>(View.java:1799) 
04-27 20:29:41.293: ERROR/AndroidRuntime(341):  at android.view.ViewGroup.<init>(ViewGroup.java:284) 

main.xml中文件,這裏是線#2

<LinearLayout 
     android:id="@+id/linearLayout3" 
     android:background="@drawable/mainbackground" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     android:orientation="vertical"> 

這裏是主線58:

public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.main); 
} 

回答

2

Caused by: java.lang.OutOfMemoryError: bitmap size exceeds VM budget可能是這裏真正的罪魁禍首。嘗試使用較小的圖像來查看它是否與內存相關的問題。

請查看以下鏈接爲類似問題的例子:java.lang.OutOfMemoryError: bitmap size exceeds VM budget - android - how many images?
OutOfMemory exception when loading bitmap from external storage

+0

我最大的繪製是44K和我剛剛strimmed下來的main.xml所以只使用了4個不同的佈局 - 很爲難! – Atkobeau 2011-04-27 21:19:36

+0

你會得到完全相同的錯誤? – Haphazard 2011-04-27 21:21:39

+2

Doh這是背景圖片,分辨率太高 – Atkobeau 2011-04-27 21:25:18

相關問題