diff --git a/lib/private/URLGenerator.php b/lib/private/URLGenerator.php
index c6f1ebd4594c1fdf1f9048763392145ac37bf131..d954153ab882f9af1e67a5375675f3ba0d69d791 100644
--- a/lib/private/URLGenerator.php
+++ b/lib/private/URLGenerator.php
@@ -158,7 +158,7 @@ class URLGenerator implements IURLGenerator {
 
 		// Check if the app is in the app folder
 		$path = '';
-		$themingEnabled = $this->config->getSystemValue('installed', false) && \OCP\App::isEnabled('theming');
+		$themingEnabled = $this->config->getSystemValue('installed', false) && \OCP\App::isEnabled('theming') && \OC_App::isAppLoaded('theming');
 		if($themingEnabled && $image === "favicon.ico" && \OC::$server->getThemingDefaults()->shouldReplaceIcons()) {
 			$cacheBusterValue = $this->config->getAppValue('theming', 'cachebuster', '0');
 			if($app==="") { $app = "core"; }