No, Google didn’t build Android from scratch. They bought it from Andy Rubin for $50M in 2005.
“In early 2005 Larry Page would agree to meet with Andy Rubin, and after hearing about his work on Android, he not just helps get the money – he decides that Google will acquire Android. The feeling that the mobile industry has had to change has already been irking Google’s cofounders, and in Mountain View Larry Page and Sergey Brin had been looking for that change for a while, particularly concerned that it might be the then big giant Microsoft that will get there first. Luckily, Rubin came in at the right time.”
“Google bought Android for around $50 million and incentives at the time, and by the middle of 2005 the whole 8-person Android team was transferred in Mountain View. And the rest, as they say, is history…”