简体   繁体   中英

The Android emulator is not reflecting changes I have made in .xml layout file

I have re-started Eclipse, re-run the application numerous times, and saved all of my files in my application. In my.xml, I have gotten rid of a button.

The.xml is inflated in my.java file. However, when I run my application on the Android emulator, it keeps showing the button that I deleted.

One possibility is your emulator is not connected to the ADB (Android Debug Bridge)

To check just do:

cd C:\Program Files (x86)\Android\android-sdk\platform-tools

adb devices

You should see

List of devices attached

emulator-5554 device

If you don't see this, manually kill the adb.exe process (DON'T kill your emulator).

Then manually run adb.exe again.

When you do adb devices you should now see your emulator. If you close/kill your emulator you may have to repeat the process again.

reinstall the application, clean the project in eclipse.

OK - I tried all this and it did not work (but I did resolve the problem...).

My project is very simple, as I am a complete newbie and had only created a mock up of the app - a simple interface and adjusted the strings XML file. None the less, I wasted a couple of hours trying to fix this damn problem. In the end, I simply generated a new project and ported all my work over. This took 10 mins and worked perfectly.

To try to learn why this happened, I repreated the steps that seemed to have caused the problem (clearing all projects, and then building them all again) - having copied all the code fromt he original project (including the manifest). I could not break it again, so am none the wiser about what caused it.

A more complicated project might be more of a challenge, but I thought I would post in any case, as I wasted a lot of time trying all these other things without sucess.

I would have thought that restarting Eclipse would have had the same effect anyway, but for what it's worth, always try Project -> Clean in situations like this.

Clean the project and then run.

The problem happened to me when I imported the project using the orginal files in Eclipse. It worked after I imported the projekt into the eclipse workspace as a copy

I had the same problem in Android Studio. When I added an imageButton it was visible in preview tab of Android Studio, but not in the emulator. I tried almost every solution mentioned in Stack Overflow for similar situation, but I didn't succeed. One of answers said that you should create a new project and copy your files into it, but this solution had a huge cost for me and I didn't want to try it. Finally I renamed my layout file in the onCreateView method:

View view = inflater.inflate(R.layout.fragment_story_edition, container, false);

Then I created a new layout resource and left it empty and ran the project in order to get an error. After that error, I copied the content of my original layout file to my new made layout file, and the problem was solved.

Uninstall the application from Setting->Application->Manage Application->Select Your app->Uninstall. and then run.It will work

To detail Rasel's answer (in addition to Project...Clean) you can also go to a shell and type adb uninstall com.example.applicationname .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM