Building an OS is hard, building an SDK is hard and so is building an IDE to go with it. Nokia is not a software company. It could not have competed with Google, Apple or Microsoft on the software platform. These companies have their own OS. They have their own browsers and even programming languages they can claim their own. They have massive developer ecosystems.
The fact that Nokia failed has little to do with Nokia itself and more to do with the disruptive power of software.
It really had just two options. Get acquired or adopt a third-party platform. Google was not interested post Motorola acquisition. Microsoft had its own demons to deal with. There was little wiggle room.
Had Motorola not been acquired, it would have gone the same route, fizzled into oblivion. RIMM is going the same route.
For all their trying, these companies don't have the software DNA.