This is a guide to a longer lasting Android device, from choosing one to how to preserve the life of the one that you have.
Choosing a long-lasting and repair friendly phone:
To get the best shot at longevity, start with a high quality device from a manufacture with a history of long term device support, and one that regularly releases there modifications to the kernel source code. A device that has an unlockable bootloader (XDA developers Forums is a good place to see about ROM support), and is user repairable (See iFixit's Smartphone Repairability Scores) will allow you to keep the software & hardware going the longest. Both the Google Pixels, and Fairphone's line are a good place to start. Fairphone is the USA is sold though Murena
Apply a screen protector. I recommend Glass, Sapphire is the best (but very expensive).
Battery
Lithium-ion (LI-on) battery's wear out faster when near the upper and lower charge levels (read why here: Battery University), so avoid charging or discarding the battery fully, aiming for around 20~80% is a good target.
Never leave your phone in a hot car or in the Sun, extreme heat exposure reduces the lifespan of the battery & is generally bad for other components.
Charging
Avoid fast & wireless charging by using a older charging block that only outputs a few(1~2) Amps. (to reduce the heat the battery endures)
Use a magnetic charging cable to reduce the wear on the plug (Like Volta), you need a bulky case to have it flush to not make the phone uncomfortable to hold though.
When/If you use a regular charging cable don't move the phone around when it's plugged in, movement wears the plug much sooner.
Use a charge limiting feature. (Listed in order of recommendation.)
If your phone has a built smart battery charge management feature, use that.
(Most modern high end phones do, including Samsung's, Google's & Apple's)
If you have Root; use ACCA(a GUI for ACC) (Suggested Charging config: Level limit: 85%, Current: 700mA, Voltage: 3800mV)
Buy a switch that can wirelessly cut off power based on charge level:
A Chargie by Lighty Electronics is a Bluetooth enabled USB-A power switch, the accompanying APP configures it to auto cut off power based on power draw or charge level. Note that in the newest Android versions/PlayStore restrictions prevent versions of the APP past v2.2.20 from auto enabling Bluetooth, making this solution a little less appealing as you have to leave Bluetooth on you manually enable it.
Using an Automation APP like Tasker to turn off a Home Assistant-controlled smart plug when the battery exceeds a reprogramed threshold, is a more reliable method & works for any device.
I don't think I've had a Pixel phone that survived much past the two year mark. They've all had various issues, either problems with the battery/charging or just dying altogether.
I still use them because you can get them for cheaper than most phones, but "longer lasting" is the last adjective I would use for them.
The Pixel 3 I have I got used and it still works, although the back glass is broken and the battery health is 85%, and stopped getting updates around a year ago. I'd say it's 5 years run so far (released October 2018) is pretty good. If you know of any other devices that would be useful for 4~7 years please share! I think high end Apple and Samsung devices would, and they are now committing to longer software support, and are likely to carry though.