Avoid:
- Having a weak military. This will cause them to be much more aggressive towards you.
- Avoid warmongersWarmongers and warmongering. AI Personalities have a huge impact on your ability to make friends & maintain that relationship. Avoid warmongering personalities such as Atilla, Genghis Khan, etc. Additionally, and this should be obvious, don't go being a warmonger yourself AI don't like this.
- Other Friendships. Being friends with an AI-A and AI-B when one or both of them hate or dislike each other will tarnish your relations with one or both of them.
- Territory. This one should be obvious but I'll list it anyways. Settling near or next to the AI you want to be friends with will cause tension between you. Additionally if you want to be friends with the AI never-ever take their territory via war OR Great Generals (Citadels). They will be angry for pretty much the rest of the game (in my experiences).
Consider:
- Trade. This is the huge one in my experience. After X turns of having an Embassy and such the AI may ask to be friends. So obviously having an Embassy is a must, open-borders doesn't hurt, and if you really want to be friends with them I've found that giving them outdated strategic resources for free helps (I always do 1 resource at a time, but that's based on a lot of assumptions on my part and no actual facts).
- Other Various actions. At times the AI will ask for assistance, doing so will increase your relationship. Having the same Ideology and/or Religion (unless you're trying to force your religion on top of theirs) improves relations too. Freeing units from Barbarian camps, Liberating their capital, Forgiving them for spying, Fighting a common enemy in war together, and not having contested borders (touching borders) all aid relations with that AI.
- Other Friendships. Being friends with an AI-A and AI-B when one or both of them hate or dislike each other will tarnish your relations with one or both of them.
- Territory. This one should be obvious but I'll list it anyways. Settling near or next to the AI you want to be friends with will cause tension between you. Additionally if you want to be friends with the AI never-ever take their territory via war OR Great Generals (Citadels). They will be angry for pretty much the rest of the game (in my experiences).
For additional info and more in-depth reading check out this link. It has a fancy table listing all the relationship modifiers (good and bad) and their magnitude of effect on your relationship with the AI (about 3/4th's down the page).
Final Words:
It's a lot easier to tarnish a relationship permanently (or close to it) with an AI than it is to make or maintain one. For the simple fact it can take only one or two actions to destroy a relationship but you have to be constantly maintaining the relationship to keep it good.
Some AI personalities will make it seem like your friends but never have the intention of keeping it going. For various reasons like they're a deceiver or they're win/goal oriented. With these AI personalities I would suggest looking up their personaility types or just remembering. (Also note this becomes miles more difficult with the Option: Random Personalities which doesn't completely scatter their personalities rather than adding/subtracting a limited value to each factor of their personality. So if they're usually a warmonger chances are they aren't going to be the most friendly given Random Personalities option.