When Google opened for business in China in 2006, Eric E. Schmidt, its chief executive, said, “Google has 5,000 years of patience in China.” But its divorce from the country just four years later was inevitable because operations there were troubled from the start.

That is the conclusion of Steven Levy, a longtime technology journalist who spent three years reporting inside the company to write “In the Plex: How Google Thinks, Works and Shapes Our Lives.” The New York Times obtained a copy of the book, which arrives in stores April 12.

The book, a wide-ranging history of the company from start-up to behemoth, sheds light on the biggest threats Google faces today, from the Chinese government to Facebook and privacy critics.

Though Google scaled back its ambitions in China after accusing government officials of breaking into company computers and activists’ Gmail accounts, a long sequence of problems led to that decision.