If you have ACF working when installed in the theme then more than likely you are trying to create your field group before ACF has loaded. In other words
if( function_exists('acf_add_local_field_group') ):
is false.
Put the code that creates field groups into an init action
add_action('init', 'my_function_to_add_field_groups');
function my_function_to_add_field_groups() {
// add field groups here
}