[방안 요약] 사진 자원이 Illegal Argument Exception 이상을 일으키는 문제

11242 단어 exception
testin 플랫폼에서 monkey test를 실행하면 "IllegalArgumentException"오류가 발생합니다. (삼성 GT-S5360)
충돌 로그
8.789E/AudioPlayer(1311):mFirstBufferResult=0
07-2217:28:48.898E/AudioPlayer(1311):mFirstBufferResult=0
07-2217:28:49.843E/AndroidRuntime(19219):FATALEXCEPTION:main
07-2217:28:49.843E/AndroidRuntime(19219):java.lang.RuntimeException:UnabletostartactivityComponentInfo{com.zhe800.hongbao/com.zhe800.hongbao.activities.MainActivity}:android.view.InflateException:BinaryXMLfileline#3:Errorinflatingclass
07-2217:28:49.843E/AndroidRuntime(19219):atandroid.app.ActivityThread.performLaunchActivity(ActivityThread.java:1651)
07-2217:28:49.843E/AndroidRuntime(19219):atandroid.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
07-2217:28:49.843E/AndroidRuntime(19219):atandroid.app.ActivityThread.access$1500(ActivityThread.java:117)
07-2217:28:49.843E/AndroidRuntime(19219):atandroid.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
07-2217:28:49.843E/AndroidRuntime(19219):atandroid.os.Handler.dispatchMessage(Handler.java:99)
07-2217:28:49.843E/AndroidRuntime(19219):atandroid.os.Looper.loop(Looper.java:130)
07-2217:28:49.843E/AndroidRuntime(19219):atandroid.app.ActivityThread.main(ActivityThread.java:3687)
07-2217:28:49.843E/AndroidRuntime(19219):atjava.lang.reflect.Method.invokeNative(NativeMethod)
07-2217:28:49.843E/AndroidRuntime(19219):atjava.lang.reflect.Method.invoke(Method.java:507)
07-2217:28:49.843E/AndroidRuntime(19219):atcom.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
07-2217:28:49.843E/AndroidRuntime(19219):atcom.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
07-2217:28:49.843E/AndroidRuntime(19219):atdalvik.system.NativeStart.main(NativeMethod)
07-2217:28:49.843E/AndroidRuntime(19219):Causedby:android.view.InflateException:BinaryXMLfileline#3:Errorinflatingclass
07-2217:28:49.843E/AndroidRuntime(19219):atandroid.view.LayoutInflater.createView(LayoutInflater.java:518)
07-2217:28:49.843E/AndroidRuntime(19219):atcom.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
07-2217:28:49.843E/AndroidRuntime(19219):atandroid.view.LayoutInflater.createViewFromTag(LayoutInflater.java:568)
07-2217:28:49.843E/AndroidRuntime(19219):atandroid.view.LayoutInflater.parseInclude(LayoutInflater.java:684)
07-2217:28:49.843E/AndroidRuntime(19219):atandroid.view.LayoutInflater.rInflate(LayoutInflater.java:619)
07-2217:28:49.843E/AndroidRuntime(19219):atandroid.view.LayoutInflater.rInflate(LayoutInflater.java:626)
07-2217:28:49.843E/AndroidRuntime(19219):atandroid.view.LayoutInflater.inflate(LayoutInflater.java:408)
07-2217:28:49.843E/AndroidRuntime(19219):atandroid.view.LayoutInflater.inflate(LayoutInflater.java:320)
07-2217:28:49.843E/AndroidRuntime(19219):atandroid.view.LayoutInflater.inflate(LayoutInflater.java:276)
07-2217:28:49.843E/AndroidRuntime(19219):atcom.zhe800.hongbao.fragments.SlidingMenuFragment.onCreateView(SlidingMenuFragment.java:71)
07-2217:28:49.843E/AndroidRuntime(19219):atandroid.support.v4.app.Fragment.performCreateView(Fragment.java:1460)
07-2217:28:49.843E/AndroidRuntime(19219):atandroid.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:911)
07-2217:28:49.843E/AndroidRuntime(19219):atandroid.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1088)
07-2217:28:49.843E/AndroidRuntime(19219):atandroid.support.v4.app.BackStackRecord.run(BackStackRecord.java:682)
07-2217:28:49.843E/AndroidRuntime(19219):atandroid.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1444)
07-2217:28:49.843E/AndroidRuntime(19219):atandroid.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:551)
07-2217:28:49.843E/AndroidRuntime(19219):atandroid.app.Instrumentation.callActivityOnStart(Instrumentation.java:1129)
07-2217:28:49.843E/AndroidRuntime(19219):atandroid.app.Activity.performStart(Activity.java:3791)
07-2217:28:49.843E/AndroidRuntime(19219):atandroid.app.ActivityThread.performLaunchActivity(ActivityThread.java:1624)
07-2217:28:49.843E/AndroidRuntime(19219):...11more
07-2217:28:49.843E/AndroidRuntime(19219):Causedby:java.lang.reflect.InvocationTargetException
07-2217:28:49.843E/AndroidRuntime(19219):atjava.lang.reflect.Constructor.constructNative(NativeMethod)
07-2217:28:49.843E/AndroidRuntime(19219):atjava.lang.reflect.Constructor.newInstance(Constructor.java:415)
07-2217:28:49.843E/AndroidRuntime(19219):atandroid.view.LayoutInflater.createView(LayoutInflater.java:505)
07-2217:28:49.843E/AndroidRuntime(19219):...29more
07-2217:28:49.843E/AndroidRuntime(19219):Causedby:android.content.res.Resources$NotFoundException:Fileres/drawable-xhdpi/img_menu_divider.pngfromdrawableresourceID#0x7f020078
07-2217:28:49.843E/AndroidRuntime(19219):atandroid.content.res.Resources.loadDrawable(Resources.java:1714)
07-2217:28:49.843E/AndroidRuntime(19219):atandroid.content.res.TypedArray.getDrawable(TypedArray.java:601)
07-2217:28:49.843E/AndroidRuntime(19219):atandroid.widget.ImageView.(ImageView.java:118)
07-2217:28:49.843E/AndroidRuntime(19219):atandroid.widget.ImageView.(ImageView.java:108)
07-2217:28:49.843E/AndroidRuntime(19219):...32more
07-2217:28:49.843E/AndroidRuntime(19219):Causedby:java.lang.IllegalArgumentException:widthandheightmustbe>0
07-2217:28:49.843E/AndroidRuntime(19219):atandroid.graphics.Bitmap.nativeCreate(NativeMethod)
07-2217:28:49.843E/AndroidRuntime(19219):atandroid.graphics.Bitmap.createBitmap(Bitmap.java:477)
07-2217:28:49.843E/AndroidRuntime(19219):atandroid.graphics.Bitmap.createBitmap(Bitmap.java:444)
07-2217:28:49.843E/AndroidRuntime(19219):atandroid.graphics.Bitmap.createScaledBitmap(Bitmap.java:349)
07-2217:28:49.843E/AndroidRuntime(19219):atandroid.graphics.BitmapFactory.finishDecode(BitmapFactory.java:601)
07-2217:28:49.843E/AndroidRuntime(19219):atandroid.graphics.BitmapFactory.decodeStream(BitmapFactory.java:576)
07-2217:28:49.843E/AndroidRuntime(19219):atandroid.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:439)
07-2217:28:49.843E/AndroidRuntime(19219):atandroid.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:697)
07-2217:28:49.843E/AndroidRuntime(19219):atandroid.content.res.Resources.loadDrawable(Resources.java:1709)
07-2217:28:49.843E/AndroidRuntime(19219):...35more
07-2217:28:49.859E/liblog(1481):failedtocalldumpstate
07-2217:28:49.867E/(1481):Dumpstate>/data/log/dumpstate_app_com_zhe800_hongbao_error
07-2217:28:51.375E/StatusBarPolicy(1542):ecio:255
07-2217:28:51.375E/StatusBarPolicy(1542):iconLevel:4
07-2217:28:54.125E/Launcher(8627):setWindowOpaque()
07-2217:28:54.164E/Launcher(8627):MTP-LAUNCHER:mediascanningnotyetfinished.
07-2217:28:54.312E/com.samsung.app(8697):[MSC]>>>StockClock_Integration.java:152[0:0]onReceivesec.android.intent.action.HOME_RESUME
07-2217:28:54.312E/com.samsung.app(8697):[MSC]>>>WidgetIdManager.java:20[0:0]SinaStockClock_WidgetID_Length201
07-2217:28:54.312E/com.samsung.app(8697):[MSC]>>>WidgetIdManager.java:21[0:0]getPrefIDs():length=0
07-2217:28:54.312E/com.samsung.app(8697):[MSC]>>>WidgetIdManager.java:20[0:0]SinaStockClock_WidgetID_Length202
07-2217:28:54.320E/com.samsung.app(8697):[MSC]>>>WidgetIdManager.java:21[0:0]getPrefIDs():length=0
07-2217:28:54.320E/com.samsung.app(8697):[MSC]>>>WidgetIdManager.java:20[0:0]SinaStockClock_WidgetID_Length204
07-2217:28:54.335E/com.samsung.app(8697):[MSC]>>>WidgetIdManager.java:21[0:0]getPrefIDs():length=0
07-2217:28:54.351E/com.samsung.app(8697):[MSC]>>>WidgetIdManager.java:20[0:0]SinaStockClock_WidgetID_Length401
07-2217:28:54.351E/com.samsung.app(8697):[MSC]>>>WidgetIdManager.java:21[0:0]getPrefIDs():length=0
07-2217:28:54.359E/com.samsung.app(8697):[MSC]>>>WidgetIdManager.java:20[0:0]SinaStockClock_WidgetID_Length402
07-2217:28:54.359E/com.samsung.app(8697):[MSC]>>>WidgetIdManager.java:21[0:0]getPrefIDs():length=0
07-2217:28:54.390E/com.samsung.app(8697):[MSC]>>>WidgetIdManager.java:20[0:0]SinaStockClock_WidgetID_Length404
07-2217:28:54.390E/com.samsung.app(8697):[MSC]>>>WidgetIdManager.java:21[0:0]getPrefIDs():length=0
07-2217:28:54.390E/com.samsung.app(8697):[MSC]>>>WidgetIdManager.java:20[0:0]SinaStockClock_WidgetID_Length411
07-2217:28:54.390E/com.samsung.app(8697):[MSC]>>>WidgetIdManager.java:21[0:0]getPrefIDs():length=0
07-2217:28:54.390E/com.samsung.app(8697):[MSC]>>>WidgetIdManager.java:20[0:0]SinaStockClock_WidgetID_Length414
07-2217:28:54.398E/com.samsung.app(8697):[MSC]>>>WidgetIdManager.java:21[0:0]getPrefIDs():length=0
07-2217:28:56.031E/AndroidRuntime(19371):/system/csc/feature.xml==>cannotopenfile
07-2217:28:56.617E/AndroidRuntime(19381):/system/csc/feature.xml==>cannotopenfile
오류 로그 추적, 문제는 다음과 같은 과정으로 지정됩니다.
07-2217:28:49.843E/AndroidRuntime(19219):Causedby:android.content.res.Resources$NotFoundException:Fileres/drawable-xhdpi/img_menu_divider.pngfromdrawableresourceID#0x7f020078
07-2217:28:49.843E/AndroidRuntime(19219):atandroid.content.res.Resources.loadDrawable(Resources.java:1714)
07-2217:28:49.843E/AndroidRuntime(19219):atandroid.content.res.TypedArray.getDrawable(TypedArray.java:601)
07-2217:28:49.843E/AndroidRuntime(19219):atandroid.widget.ImageView.(ImageView.java:118)
07-2217:28:49.843E/AndroidRuntime(19219):atandroid.widget.ImageView.(ImageView.java:108)
07-2217:28:49.843E/AndroidRuntime(19219):...32more
07-2217:28:49.843E/AndroidRuntime(19219):Causedby:java.lang.IllegalArgumentException:widthandheightmustbe>0
07-2217:28:49.843E/AndroidRuntime(19219):atandroid.graphics.Bitmap.nativeCreate(NativeMethod)
07-2217:28:49.843E/AndroidRuntime(19219):atandroid.graphics.Bitmap.createBitmap(Bitmap.java:477)
07-2217:28:49.843E/AndroidRuntime(19219):atandroid.graphics.Bitmap.createBitmap(Bitmap.java:444)
07-2217:28:49.843E/AndroidRuntime(19219):atandroid.graphics.Bitmap.createScaledBitmap(Bitmap.java:349)
07-2217:28:49.843E/AndroidRuntime(19219):atandroid.graphics.BitmapFactory.finishDecode(BitmapFactory.java:601)
07-2217:28:49.843E/AndroidRuntime(19219):atandroid.graphics.BitmapFactory.decodeStream(BitmapFactory.java:576)
07-2217:28:49.843E/AndroidRuntime(19219):atandroid.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:439)
07-2217:28:49.843E/AndroidRuntime(19219):atandroid.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:697)
07-2217:28:49.843E/AndroidRuntime(19219):atandroid.content.res.Resources.loadDrawable(Resources.java:1709)

로그에 따르면 오류는img_menu_divider.png 이 사진은 일으킨 것을 찾지 못했습니다.다시 자세히 보니 그림의 넓이와 높이가 0보다 작기 때문에java가 생겼다.lang.IllegalArgumentException:widthandheightmustbe>0.
이 그림에 문제가 있어서android 프레임워크를 불러올 수 없을 것 같습니다.
솔루션
그림 자원을 색 값으로 대체합니다. 코드는 다음과 같습니다.
<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="0.5dp"
    android:paddingTop="0.0dp"
    android:paddingBottom="0.0dp"
    android:layout_marginLeft="20dp"
    android:background="#ffb297" >
</ImageView>

좋은 웹페이지 즐겨찾기