Displaying validation message in options-general.php

I was developing locally with Local, so I tested in the online version, where it worked. I then deactivated most of the plug-ins locally, and it started to work. I might have also stopped the site and run it again, I am not sure, but it might have helped? Anyway, after reactivating all the same plug-ins, it kept working, so I guess that some of the actions above have helped. Here it the complete working solution.

<?php
//... The content of functions.php until here

add_action( 'admin_init', 'initialize_extra_settings' );
function initialize_extra_settings( ) {
  register_setting( 'general', 'setting_app_store_app_url', array(
     'type' => 'string',
    'sanitize_callback' => function( $value ) {
      return settings_url_field_validation( $value, 'setting_app_store_app_url', 'App store app url' );
    } 
  ) );
  register_setting( 'general', 'setting_android_app_url', array(
     'type' => 'string',
    'sanitize_callback' => function( $value ) {
      return settings_url_field_validation( $value, 'setting_android_app_url', 'Android app url' );
    } 
  ) );
  // Register new fields in the sections
  add_settings_field( 'app-store-app-url-field', // Field slug
    'App Store app URL', 'app_store_app_url_field_cb', 'general', // In this settings page (slug)
    'default', // In this section (slug)
    array(
     'label_for' => 'app-store-app-url-field',
    'class' => 'custom-settings-row' 
  ) );
  add_settings_field( 'android-app-url-field', // Field slug
    'Android app URL', 'android_app_url_field_cb', 'general', // In this settings page (slug)
    'default', // In this section (slug)
    array(
     'label_for' => 'android-app-url-field',
    'class' => 'custom-settings-row' 
  ) );
}

function app_store_app_url_field_cb( $args ) {
  $setting = get_option( 'setting_app_store_app_url' );
?>
   <input 
        id="<?php echo $args['label_for']; ?>" 
        name="setting_app_store_app_url" 
        type="url" 
        value="<?php echo isset( $setting ) ? esc_attr( $setting ) : ''; ?>"  
    />
    <?php
}

function android_app_url_field_cb( $args ) {
  $setting = get_option( 'setting_android_app_url' ); // The name used in the register_setting call
?>
   <input 
        id="<?php echo $args['label_for']; ?>" 
        name="setting_android_app_url" 
        type="url"
        value="<?php echo isset( $setting ) ? esc_attr( $setting ) : ''; ?>"  
    />
    <?php
}

function settings_url_field_validation( $value, $field, $name ) {
  $urlRegExp = "/https:\/\/([\w_-]+(?:(?:\.[\w_-]+)+))([\w.,@?^=%&:\/~+#-]*[\w@?^=%&\/~+#-])/";
  if ( !preg_match( $urlRegExp, $value ) ) {
    $value = get_option( $field ); // ignore the user's changes and use the old database value
    add_settings_error( $field, $field, $name . ' must be a valid url', 'error' );
    return $value;
  }
  return $value;
}
?>