title: App crashes without showing permission dialog, but works fine when permission is granted manually
body: <p>I am relatively new to Android development. I have an app which requires the certain permissions. These are added in the <code>AndroidManifest.xml</code>:</p>
  
  <pre><code>    &lt;uses-permission android:name="android.permission.INTERNET" /&gt;
      &lt;uses-permission android:name="android.permission.CAMERA" /&gt;
      &lt;uses-permission android:name="android.permission.STORAGE"/&gt;
      &lt;uses-permission android:name="android.permission.PHONE"/&gt;
      &lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /&gt;
      &lt;uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /&gt;
      &lt;uses-permission android:name="android.permission.CALL_PHONE" /&gt;
      &lt;uses-permission android:name="android.permission.READ_PHONE_STATE" /&gt;
      &lt;uses-permission android:name="android.permission.VIBRATE" /&gt;
      &lt;uses-permission android:name="android.permission.READ_LOGS" /&gt;
      &lt;uses-permission android:name="android.permission.READ_CALL_LOG" /&gt;
      &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /&gt;
      &lt;uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" /&gt;
      &lt;uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /&gt;
      &lt;uses-permission android:name="android.permission.WAKE_LOCK" /&gt;
  </code></pre>
  
  <p>The app crashes on initial start (both on emulated device and installed apk) but after granting the <strong>CAMERA</strong>, <strong>PHONE</strong> and <strong>STORAGE</strong> permissions manually from the settings of phone, it works fine. </p>
  
  <p>In the <code>MainActivity</code>, I have also added permission check like these (in <code>onCreate</code>):</p>
  
  <pre><code> // CAMERA permission
   if (ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) {
      // Permission is not granted
      ActivityCompat.requestPermissions(this,
         new String[]{Manifest.permission.CAMERA},
             1);
          }
  </code></pre>
  
  <p>But the app keeps crashing on start without showing the permission dialog. What am I doing wrong here?</p>
  
  <p><strong>EDIT</strong>
  Error trace:</p>
  
  <p><a href="https://i.stack.imgur.com/lC7cM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lC7cM.png" alt="enter image description here"></a></p>