title: Magento 2 : Custom Module not working
body: <p>I have created a simple custom module in Magento 2. But its not working. Could anyone please suggest me where I went wrong?</p>
  
  <p><strong>My Code is</strong></p>
  
  <p><strong>app/etc/config.xml</strong></p>
  
  <pre><code>'Sparx_Helloworld' =&gt; 1,
  </code></pre>
  
  <p><strong>app/code/Sparx/Helloworld/etc/module.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd"&gt;
      &lt;module name="Sparx_Helloworld" schema_version="0.0.1" active="true"&gt;
      &lt;/module&gt;
  &lt;/config&gt;
  </code></pre>
  
  <p><strong>app/code/Sparx/Helloworld/Controller/Index/Index.php</strong></p>
  
  <pre><code>&lt;?php
  namespace Sparx\Helloworld\Controller\Index;
  class Index extends \Magento\Framework\App\Action\Action
  {
      public function execute()
      {
          $this-&gt;_view-&gt;loadLayout();
          $this-&gt;_view-&gt;getLayout()-&gt;initMessages();
          $this-&gt;_view-&gt;renderLayout();
      }
  }
  </code></pre>
  
  <p><strong>app/code/Sparx/Helloworld/Block/Helloworld.php</strong></p>
  
  <pre><code>&lt;?php
  namespace Sparx\Helloworld\Block;
  class Helloworld extends \Magento\Framework\View\Element\Template
  {
      public function _prepareLayout()
      {
          return parent::_prepareLayout();
      }
  }
  </code></pre>
  
  <p><strong>app/code/Sparx/Helloworld/etc/frontend/routes.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/App/etc/routes.xsd"&gt;
      &lt;router id="standard"&gt;
          &lt;route id="helloworld" frontName="helloworld"&gt;
              &lt;module name="Sparx_Helloworld" /&gt;
          &lt;/route&gt;
      &lt;/router&gt;
  &lt;/config&gt;
  </code></pre>
  
  <p><strong>app/code/Sparx/Helloworld/etc/view/frontend/layout/helloworld_index_index.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd"&gt;
      &lt;head&gt;
          &lt;title&gt;Welcome to Magento World&lt;/title&gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;referenceContainer name="content"&gt;
              &lt;block name="helloworld" template="helloworld.phtml"&gt;
              &lt;/block&gt;
          &lt;/referenceContainer&gt;
      &lt;/body&gt;
  &lt;/page&gt;
  </code></pre>
  
  <p><strong>app/code/Sparx/Helloworld/view/frontend/templates/helloworld.phtml</strong></p>
  
  <pre><code>&lt;?php echo 'Successful! This is a simple helloworld module in Magento 2'; ?&gt;
  </code></pre>
  
  <p><strong>I getting below error</strong>
  <a href="https://i.stack.imgur.com/1dmcU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1dmcU.png" alt="enter image description here"></a></p>
  
  <p><strong>I'm not sure what is wrong. Please do the needful.</strong></p>
  
  <p>Thanks</p>