title: Ionic 4 is showing invalid JAVA_HOME path on apk build but it's already exists and the path exists
body: <p>I am trying to build an apk out of my ionic project. When I use both commands:</p>
  
  <pre><code>ionic build cordova android
  
  ionic build cordova --release android
  </code></pre>
  
  <p>The script runs normally with no errors show, but no APK file is generated.</p>
  
  <p>I tried to remove the platform and add it again, and then repeat the process using one of commands above:</p>
  
  <pre><code>ionic cordova platform rm android
  
  ionic cordova platform add android
  </code></pre>
  
  <p>And still the same.</p>
  
  <p>I tried to debug the app using:</p>
  
  <pre><code>cordova build --release android
  </code></pre>
  
  <p>And an error appeared:</p>
  
  <blockquote>
    <p>Your JAVA_HOME is invalid: C:\Program Files\Java\jre1.8.0_181\bin</p>
  </blockquote>
  
  <p>But I checked the path and it's correct. Here is my <code>PATH</code> and <code>JAVA_HOME</code> env variables:</p>
  
  <p>At the PATH variable:</p>
  
  <pre><code>C:\Program Files\Java\jre1.8.0_181\bin;C:\Program Files\Java\jdk1.8.0_241\bin;
  </code></pre>
  
  <p>I am using both because when I remove one of them it will ask for it.</p>
  
  <p>And the JAVA_HOME:</p>
  
  <p><a href="https://i.stack.imgur.com/L1ndO.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/L1ndO.jpg" alt=""></a></p>