Troubleshooter. How to deal with ‘Fatal error: Cannot redeclare class Mobile_Detect’

You may face the errors and warning messages described below during/after template installation. Let’s take a closer look at how to resolve them.

Warning: require_once(public_html\templates\themeXXX\includes\Mobile_Detect.php): failed to open stream: No such file or directory in public_html/templates/themeXXX/html/modules.php on line 5

Fatal error: require_once(): Failed opening required ‘public_html\templates\themeXXX\includes\Mobile_Detect.php’ (include_path=’.:/opt/php54/lib/php’) in public_html/templates/themeXXX/html/modules.php on line 5

In order to fix the warning or error which you can see above, you will need to edit templates/themeXXX/html/modules.php file.

    1. First of all, connect to FTP or locate the file with a help of Hosting cPanel file manager, download the file to your computer and open in any code editor tool.  Replace the code at the 5th line:

      With this one:

      [notice type=”warning”]Note! The code at the 5th line which you can see in your modules.php may differ, but its correct structure is specified above.

    2. Save the changes and re-upload the file back to templates/themeXXX/html/ folder accepting the file replacement. You will see that the error message is gone.
One more variant of the same error:

Warning: require_once(includesDSMobile_Detect.php): failed to open stream: No such file or directory in public_html/templates/themeXXX/offline.php on line 18

Fatal error: require_once(): Failed opening required ‘includesDSMobile_Detect.php’ (include_path=’. ; ; Windows: \path1′) in public_html/templates/themeXXX//offline.php on line 18

In order to fix the warning or error which you can see above, you will need to edit templates/themeXXX/offline.php file.

  1. First of all, connect to FTP or locate the file with a help of Hosting cPanel file manager, download the file at your PC and open in any code editor tool.  Approximately at lines 17-18 you will see the following code: 
  2. You need to edit it the following way:
  3. Save the changes and re-upload the file back to templates/themeXXX/html/ folder accepting the file replacement. You will see that the error message is gone.

Now you know how to fix the errors which can appear on your website.

 

shopify subscription price