A solution where replacing resource images in Android development does not work
- 2020-06-01 10:59:04
The phenomenon of
In the development of android, 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 emulator or real machine, it is found that the image has not been replaced and the original resource image is still used.
During the development process, because the program was tested using the simulator, the image resource files in the res folder (such as drawable-hdpi, drawable-ldpi, and drawable-mdpi) were copied into the bin folder after the first run. After replacing the resource image, eclipse does not know whether the image has changed or not, so it will package the resource file in the res folder under the original bin, and the image will use the file copied by eclipse in the first time. Therefore, when running the program, it will find that the replacement resource image has no effect in the program.
Now that it is clear that eclipse has not copied the latest resource files, we only need to delete the res directory under the project bin directory (which can be deleted together with the three file 1 generated under bin:.apk,.dex and.ap_), and then generate the apk files from the project.
Each run will copy the res folder under bin. Since eclipse does not know whether the image has changed when the image is replaced, it will package the resource files in res under bin, so the image will remain the same
All you have to do is go to the bin directory and delete the res directory (along with the apk,dex,ap_ files 1 generated under bin)
In addition, there is one classes under bin, which should be the class file generated by the corresponding java file