Drupal : Fatal error: Cannot redeclare class Mobile_Detect



So I decided to ad mobile web pages on my site. When I used the Mobile_Detect.php file in my library I occasionally got the following error:

Fatal error: Cannot redeclare class Mobile_Detect in <Path>/libraries/Mobile_Detect/Mobile_Detect.php on line 27

The solution was to find in the Mobile_Detect.php nere the line number in the error:

class Mobile_Detect

Change it to:


class Mobile_Detect

Then at the end of the Mobile_Detect.php file, clise the tag with a closing "}"


That seemed to work for me.

This website and its content is copyright of ITHierarchy Inc - © ITHierarchy Inc 2013-2015. All rights reserved.

Any redistribution or reproduction of part or all of the contents in any form is prohibited other than the following:

  • you may print or download to a local hard disk extracts for your personal and non-commercial use only
  • you may copy the content to individual third parties for their personal use, but only if you acknowledge the website as the source of the material

You may not, except with our express written permission, distribute or commercially exploit the content. Nor may you transmit it or store it in any other website or other form of electronic retrieval system.