Customize a view and deploy it in the layout file. The execution program reports the following error:
E/AndroidRuntime( 1292): FATAL EXCEPTION: mainE/AndroidRuntime( 1292): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.raycommtech/com.raycommtech.HomecloudActivity}: android.view.InflateException: Binary XML file line #2: Error inflating class android.widget.AbsoluteLayoutE/AndroidRuntime( 1292): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)E/AndroidRuntime( 1292): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)E/AndroidRuntime( 1292): at android.app.ActivityThread.access$1500(ActivityThread.java:117)E/AndroidRuntime( 1292): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)E/AndroidRuntime( 1292): at android.os.Handler.dispatchMessage(Handler.java:99)E/AndroidRuntime( 1292): at android.os.Looper.loop(Looper.java:130)E/AndroidRuntime( 1292): at android.app.ActivityThread.main(ActivityThread.java:3683)E/AndroidRuntime( 1292): at java.lang.reflect.Method.invokeNative(Native Method)E/AndroidRuntime( 1292): at java.lang.reflect.Method.invoke(Method.java:507)E/AndroidRuntime( 1292): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)E/AndroidRuntime( 1292): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)E/AndroidRuntime( 1292): at dalvik.system.NativeStart.main(Native Method)E/AndroidRuntime( 1292): Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class android.widget.AbsoluteLayoutE/AndroidRuntime( 1292): at android.view.LayoutInflater.createView(LayoutInflater.java:518)E/AndroidRuntime( 1292): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)E/AndroidRuntime( 1292): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:568)E/AndroidRuntime( 1292): at android.view.LayoutInflater.inflate(LayoutInflater.java:386)E/AndroidRuntime( 1292): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)E/AndroidRuntime( 1292): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)E/AndroidRuntime( 1292): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:207)E/AndroidRuntime( 1292): at android.app.Activity.setContentView(Activity.java:1657)E/AndroidRuntime( 1292): at com.raycommtech.HomecloudActivity.onCreate(HomecloudActivity.java:92)E/AndroidRuntime( 1292): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)E/AndroidRuntime( 1292): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)E/AndroidRuntime( 1292): ... 11 moreE/AndroidRuntime( 1292): Caused by: java.lang.reflect.InvocationTargetExceptionE/AndroidRuntime( 1292): at java.lang.reflect.Constructor.constructNative(Native Method)E/AndroidRuntime( 1292): at java.lang.reflect.Constructor.newInstance(Constructor.java:415)E/AndroidRuntime( 1292): at android.view.LayoutInflater.createView(LayoutInflater.java:505)E/AndroidRuntime( 1292): ... 21 moreE/AndroidRuntime( 1292): Caused by: android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x1/d=0x7f020020 a=-1 r=0x7f020020}E/AndroidRuntime( 1292): at android.content.res.Resources.loadDrawable(Resources.java:1681)E/AndroidRuntime( 1292): at android.content.res.TypedArray.getDrawable(TypedArray.java:601)E/AndroidRuntime( 1292): at android.view.View.<init>(View.java:1951)E/AndroidRuntime( 1292): at android.view.View.<init>(View.java:1899)E/AndroidRuntime( 1292): at android.view.ViewGroup.<init>(ViewGroup.java:286)E/AndroidRuntime( 1292): at android.widget.AbsoluteLayout.<init>(AbsoluteLayout.java:47)E/AndroidRuntime( 1292): ... 24 more
At first, I thought there was a problem with the custom view overload method. I also checked a lot of errors related to the custom view on the Internet, or the problem was solved.
A closer look at the error is that the resource file is not found. Check the resource files under Res/and put them all under the drawable-mdpi/directory. Suddenly, the resource file does not exist, therefore, copy the resource files under drawable-mdpi/to the drawable-ldpi/directory, or report the errors, and copy the files to the drawable-hdpi/directory, solve the problem.
Another solution is to create a directory named drawable/under Res/and copy all the resource files under drawable-mdpi/to drawable /.