Android eclipse debugging reports java. lang. ClassCastException exception, androidexception
In the layout file, place the ImageView position before the Button for the first time.
Code compilation Error
Then adjust the positions of the two
The following error is reported during re-compilation.
The error message "Why is this error reported when the Button type cannot be converted to the ImageView type? I did not explicitly set the conversion between them.
It turns out that eclipse compilation is based on the timestamp-based judgment mechanism.
So when you press build all, some classes that eclipse considers that the timestamp has not changed will not be compiled.
Therefore, you can first clean and then compile. At this time, eclipse will clear all previous compilation information and then compile it.
After the two controls are re-compiled, you can clear the. class file generated by compilation from project-> clean.
Then compile again. No error is reported.
I used eclipse to debug the android program. It was okay to run it for the first time. After the change, I ran eclipse for the second time. I didn't respond at all.
Increase eclipse configuration. All are in eclipse. ini. Try it.
What happens to a javalangClassCastException?
Type conversion error ..
For example, if you have A class A and B class, there is no relationship between the two classes ..
Then you A a = new ();
B B = (B);
In this way, this exception will be reported during the runtime ..
But if your class B inherits from Class A, it won't ..
If you want to avoid this error ..
You can check whether the. a object is of type B before transformation... use the instanceof keyword ..
For example, if (a instanceof B) {B B = (B) ..