title: The application could not be installed. Installation failed due to: 'Invalid File: <path>.apk
body: <p>I am trying to run the app on Note8 device using Android Studio and facing this issue after updating the variant output Directory path inside app/build.gradle file. There are lot of similar kind of issues I have seen, but none of their solutions are working for me.</p>
  <p>I am on Android studio 3.6.+ and note 8 device, Also the funny things is path it's showing doesn't exist currently, it is the old path for variant.output in my app/build.gradle file.</p>
  <p>changes after which the error started:</p>
  <pre><code>applicationVariants.all { variant -&gt;
      variant.outputs.each { output -&gt;
          def outputDir = new File(&quot;${project.buildDir.absolutePath}/outputs/apk&quot;)
          def outputFileName = &quot;DEMO-${variant.flavorName}-Build-${versionName}.apk&quot;
          variant.packageApplicationProvider.get().outputDirectory = new File(&quot;$outputDir&quot;)
          output.outputFileName = outputFileName
      }
  }
  </code></pre>
  <p>before changes: outputDir is the  where it's showing the file is missing error.</p>
  <pre><code>def outputDir = new File(&quot;${project.buildDir.absolutePath}/outputs/apk/${variant.flavorName}/${variant.buildType.name}&quot;)
  def outputFileName = &quot;DEMO-${variant.flavorName}-${variant.buildType.name}-${versionName}.apk&quot;
          
  </code></pre>
  <p>Things I have tried so far:
  I have tried clean and rebuild project, I have tried invalid cache and restart, I have tried deleting .idea, cache and .build directories, Also I have no application with the same package name already installed in my device.</p>
  <p>Could some one suggest the possible cause and how to resolve it?</p>