Solution to the failure of replacing resource images in Android Development

phenomenon

In Android development, it is often necessary to replace the image in res \ drawable. Open the file preview layout page under res \ layout and find that the image has been replaced, but when running on the simulator or real machine, it is found that the image has not been replaced, or the original resource image is used.

reason

During the development process, because the program is tested with the simulator, the image resource files in the res folder (such as drawable hdpi, drawable LDPI and drawable MDPI) will be copied to the bin folder after the first run. After replacing the resource image, eclipse does not know whether there is a change in the image, so it will use the resource file in the res folder under the original bin for packaging, and the image is still the file copied by eclipse for the first time. Therefore, after running the program, it will be found that the replacement resource image does not work in the program.

resolvent

Since it is understood that eclipse did not copy the latest resource files, we only need to delete the res directory under the project bin directory (together with the. APK,. DEX and. Ap_ files generated under the bin), and then generate the APK file.

Other supplements:

Each run will copy the res folder to bin. When replacing the picture, eclipse does not know whether there is a picture change, so it will use the resource file in res under the original bin for packaging, so the picture is still the original

You only need to delete the res directory from the bin directory of the project (it can be deleted together with the APK, DEX, ap_ files generated under the bin)

In addition, there is a class under bin, which should be the class file generated by the corresponding java file

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>