2014-11-23 160 views
0

我有一個Android應用程序具有在2.1最低SDK和我收到的開發者控制檯下面的堆棧跟蹤:如何解決堆棧跟蹤誤差

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.versions.MyPhone}: android.view.InflateException: Binary XML file line #2: Error inflating class <unknown> 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2705) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2721) 
at android.app.ActivityThread.access$2300(ActivityThread.java:132) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2071) 
at android.os.Handler.dispatchMessage(Handler.java:99) 
at android.os.Looper.loop(Looper.java:123) 
at android.app.ActivityThread.main(ActivityThread.java:4669) 
at java.lang.reflect.Method.invokeNative(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:521) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:876) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:634) 
at dalvik.system.NativeStart.main(Native Method) 
Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class <unknown> 
at android.view.LayoutInflater.createView(LayoutInflater.java:513) 
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56) 
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:385) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:320) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:276) 
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:203) 
at android.app.Activity.setContentView(Activity.java:1656) 
at com.versions.MyPhone.onCreate(MyPhone.java:49) 
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2669) 
... 11 more 
Caused by: java.lang.reflect.InvocationTargetException 
at android.widget.LinearLayout.<init>(LinearLayout.java:115) 
at java.lang.reflect.Constructor.constructNative(Native Method) 
at java.lang.reflect.Constructor.newInstance(Constructor.java:446) 
at android.view.LayoutInflater.createView(LayoutInflater.java:500) 
... 21 more 
Caused by: java.lang.OutOfMemoryError: bitmap size exceeds VM budget 
at android.graphics.Bitmap.nativeCreate(Native Method) 
at android.graphics.Bitmap.createBitmap(Bitmap.java:468) 
at android.graphics.Bitmap.createBitmap(Bitmap.java:435) 
at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:340) 
at android.graphics.BitmapFactory.finishDecode(BitmapFactory.java:488) 
at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:462) 
at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:323) 
at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:697) 
at android.content.res.Resources.loadDrawable(Resources.java:1709) 
at android.content.res.TypedArray.getDrawable(TypedArray.java:601) 
at android.view.View.<init>(View.java:1885) 
at android.view.View.<init>(View.java:1834) 
at android.view.ViewGroup.<init>(ViewGroup.java:285) 

的錯誤不會在發生更新Os的新設備。

請幫我解決問題或指出我的方向正確。

+0

什麼是您嘗試調整大小的圖像擴展名(png.jpg)? – Sanghita 2014-11-23 04:22:06

+0

.png擴展。 – Si8 2014-11-23 04:24:09

+0

檢查它,可能是重複的:http://stackoverflow.com/questions/12996210/android-view-inflateexception-binary-xml-file-line-2-error-inflating-class-u – 2014-11-23 04:49:13

回答

1

根據堆棧跟蹤中的java.lang.OutOfMemoryError: bitmap size exceeds VM budget消息,看起來在您的onCreate()中打開的視圖中的一個圖像太大。

這裏有一個page一些指導。主要想法是加載縮小版本的圖像。我發現最好還可以縮小實際圖像文件(分辨率,顏色深度等)以最大化加載速度。