问题
Somehow, whatever code I add to my program it does not run on my android device. It just runs my old code.
- I am constantly deleting my app from my phone in the App Manager.
- If I add new or change functionality the old code still runs.
- I even delete complete blocks of code that should obliterate functionality. But somehow all the old functionality remains in the app after reinstall.
Simple example: On a TextButton click i shift some UI element by 200. This works great. When i delete the complete button listener it still works great but i guess completely by itself since the code should be gone.
- I tried restarting Eclipse without luck.
This thing is driving me crazy. I was stuck for hours on some simple code and baffled why it did not run. Then I discovered my logs where not showing in logcat. Somehow, sometimes it does update the new code into the device since now i have a log on device resume but i deleted that at least 30 minutes ago and now it is still showing in my logcat.
Desktop app works as it should. I somehow have the feeling this happened before and over time this got worse, up to this point where i cannot test anything anymore.
So to be clear:
- I add code to my app.
- Run it from eclipse as Android application
- No changes show up
- Delete app from phone using the phones Application Manager
- Delete a complete code block like the
show()
method that holds my complete stage - Run it from eclipse as Android application
- App still runs as it was with the complete stage in tact.
-- edit --
Now I did not do anything to my code for a while and ran it. Now it probably took the code with the version with the empty show() method. However this already has been undone in the present. Could eclipse be stacking runs?
回答1:
Check
"Project -> Build Automatically"
is checked. (Most likely your problem).
Also doing a
"Project -> Clean..."
tells the IDE to delete any previously compiled binaries and rebuilds them. (The APK file).
回答2:
This could happen if there is an error in your code and you have selected run without warning when error in program exists. In such a case the last successfully built code would get pushed! As Lestat mentioned try doing a clean, if the project now shows up errors you have your culprit, else make sure your XML files are all proper.
Another check could be to see the timestamp of the last generated apk file in your workspace.
PS: There is a bug in eclipse where it doesnt save a file at time, a simple workspace restart fixes this.
回答3:
Had the same issue - updated my code and yet the phone was running the old.
- Tried Build --> Clean Project
- Tried File --> Invalidate Caches/Restart Now it works and recognizes the new code!
That said curious what #1 and #2 did behind the scenes??
来源:https://stackoverflow.com/questions/26206715/running-my-new-code-runs-my-old-code