There are more than two different spoken Chinese dialects in China.
Most villages and towns throughout China developed their own style of pronunciation and ways of communicating.
Therefore, there are several general areas of dialects, and depending on how you want to categorize them, hundreds of variations on these. Some of the main ones include Mandarin, Jin, Cantonese, Gan, Xiang, Min, Hakim, and Wu.
But thankfully, there is but one written language, making it possible for any literate Chinese to communicate with any other literate Chinese despite existing language barriers.
The reason the written form has remained is primarily because it isn’t a phonetic written language, like most other languages, but a pictorial language. Each character in the Chinese written language is a picture, and each picture represents a word.
In theory, that word can be pronounced any way you would like; the picture will always mean the same thing.
Although the written language has been simplified and streamlined over the years, it has remained largely unchanged and continues to offer a communication bridge, a unifying link, in a single country vast enough to have developed so many different spoken tongues.