Having a building from a competing franchise is a first step. Both Sony and Marvel would benefit from a collaboration, but it would take some massive egos to be pushed aside in order to let awesomeness ensue.
It has less to do with ego and more to do with business. These are brands they have to sustain and protect. Studios will always go where the money is, and right now Marvel is printing it. Amazing Spider-Man is the lowest grossing film in that franchise; they have to be looking at ways to keep those numbers up, so a potential Avengers crossover is something to look at seriously. Then the main problems are logistical; once the continuities are merged they have to figure out how to maintain them. Marvel controls the continuity in their movies, but they wouldn't control Spider-Man's unless there's a stipulation in this hypothetical agreement with SONY that gives them authority over certain creative aspects regarding timelines, places, events, etc. This would be fairly doable if they did it right now since Spidey just got rebooted, but that window of opportunity probably shrinks the longer they wait to do it.
A Wolverine/X-Men crossover would have to be a cross-dimensional/alternate-earth type of thing. There's really no reconciling those two universes otherwise. One side visits the other, comes back home, and the mess made is minimal.