Andorid exception: Binary XML file line#: Error inflating class

Keywords: Java Android xml

This exception occurred in a custom view that I wrote. Once it runs, it will report an error. Now post the log.

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.demo.demo01/com.demo.demo01.MainActivity}: android.view.InflateException: Binary XML file line #10: Error inflating class com.demo.demo01.IdentifyImageView
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2219)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2269)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5045)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #10: Error inflating class com.demo.demo01.IdentifyImageView
at android.view.LayoutInflater.createView(LayoutInflater.java:620)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:292)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at com.demo.demo01.MainActivity.onCreate(MainActivity.java:11)
at android.app.Activity.performCreate(Activity.java:5231)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1104)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2163)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2269) 
at android.app.ActivityThread.access$800(ActivityThread.java:135) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:136) 
at android.app.ActivityThread.main(ActivityThread.java:5045) 
at java.lang.reflect.Method.invokeNative(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:515) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595) 
at dalvik.system.NativeStart.main(Native Method) 
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at android.view.LayoutInflater.createView(LayoutInflater.java:594)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:755) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:492) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:397) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:353) 
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:292) 
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) 
at com.demo.demo01.MainActivity.onCreate(MainActivity.java:11) 
at android.app.Activity.performCreate(Activity.java:5231) 
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1104) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2163) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2269) 
at android.app.ActivityThread.access$800(ActivityThread.java:135) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:136) 
at android.app.ActivityThread.main(ActivityThread.java:5045) 
at java.lang.reflect.Method.invokeNative(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:515) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595) 
at dalvik.system.NativeStart.main(Native Method) 
Caused by: android.content.res.Resources$NotFoundException: File res/mipmap-xhdpi-v4/test1.jpg from drawable resource ID #0x7f030002: .xml extension required
at android.content.res.Resources.loadColorStateList(Resources.java:2260)
at android.content.res.TypedArray.getColor(TypedArray.java:320)
at android.support.v7.widget.TintTypedArray.getColor(TintTypedArray.java:128)
at com.demo.demo01.IdentifyImageView.init(IdentifyImageView.java:73)
at com.demo.demo01.IdentifyImageView.<init>(IdentifyImageView.java:59)
at com.demo.demo01.IdentifyImageView.<init>(IdentifyImageView.java:49)
at java.lang.reflect.Constructor.constructNative(Native Method) 
at java.lang.reflect.Constructor.newInstance(Constructor.java:423) 
at android.view.LayoutInflater.createView(LayoutInflater.java:594) 
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:755) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:492) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:397) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:353) 
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:292) 
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) 
at com.demo.demo01.MainActivity.onCreate(MainActivity.java:11) 
at android.app.Activity.performCreate(Activity.java:5231) 
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1104) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2163) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2269) 
at android.app.ActivityThread.access$800(ActivityThread.java:135) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:136) 
at android.app.ActivityThread.main(ActivityThread.java:5045) 
at java.lang.reflect.Method.invokeNative(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:515) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595) 
at dalvik.system.NativeStart.main(Native Method) 

Baidu has a lot of reasons, and it doesn't work if you try.
You can only sink in and look at the log again, and find that one of the logs in the log error is located in the following line of code each time.

bigImage = tta.getDrawable(R.styleable.IdentifyImageView_idiv_bigimage);
smallImage = tta.getDrawable(R.styleable.IdentifyImageView_idiv_smallimage);
angle = tta.getFloat(R.styleable.IdentifyImageView_idiv_angle,45);//Default plot and progress bar
radiusScale = tta.getFloat(R.styleable.IdentifyImageView_idiv_radiusscale,0.28f);//Default Ratio of Big Map and Small Map
isProgress = tta.getBoolean(R.styleable.IdentifyImageView_idiv_isprogress,false);//Default no progress bar
progressColor = tta.getColor(R.styleable.IdentifyImageView_idiv_progress_color,0);
borderColor = tta.getColor(R.styleable.CircleImageView_civ_border_color,0);
borderWidth = tta.getInteger(R.styleable.IdentifyImageView_idiv_border_width,0);
hintSmallView = tta.getBoolean(R.styleable.IdentifyImageView_idiv_hint_smallimageview,false);//Default does not hide small icons

Feeling that the problem should be here, and then look at it one by one, one of the references is wrong, it refers to third-party libraries in the project.
Because a data name duplicates a data in a third-party library when customizing attributes, the smart prompt directly imports a reference from a third-party library when writing code, resulting in an error. This tells us a truth.

Write code carefully!!!
Write code carefully!!!
Write code carefully!!!

Then the problem was solved!

When solving the problem, we also found some other ways to solve similar abnormalities. Put down the link for your reference!

link

Posted by duncanwil on Sun, 10 Feb 2019 10:03:18 -0800