Oh yes, it happened to me too. It's not like that is some random surprise either though. When they don't want friendship while being in the green, you know something is up. In the last case i noticed this, it was because they had a settler on it's way to settle the contested area between us. As soon as their settler got to settle, they wanted friendship. Quite possibly if i had settled there first it would have been war. In this case it is quite obvious, we know the AI doesn't like you settling near them while they do like to do it against you, i don't know what other reasons they may have, but they aren't doing total surprise attacks. When it's green and they dont want to befriend, beware. See if there's anything that might provoke war and don't do it if you don't want war. And "beware" doesn't mean build an army, to me it means having a few units, being ready to build and buy more and to be ready to finish the tech to upgrade them.
Barbarians are a nuisance on default setting. 2-3 total units are normally plenty to deal with that.