You’re probably calling the BP function before BP has loaded.
Read this: https://codex.buddypress.org/plugindev/checking-buddypress-is-active/
There may be additional problems with your code including the issue raised by @henrywright
You should be able to use
friends_get_friend_count_for_user()in your plugin. Are you sure you have BP activated? Are you sure you have the Friends component enabled?
@mika89 Active 6 years, 10 months ago