title: Staging app.... There was a problem parsing the package
body: <p>I made an app <code>Ave</code> that updates through my website downloading a <code>ave.apk</code> package. Install from unknown sources is allowed for the app. It has been working great for years.</p>
  <p>The update process still work perfectly in Android 4.4 and Andoid 9. But in Android 11, after downloading the new <code>ave.apk</code>, I get an error, with two popups. One below with a progress saying:</p>
  <pre><code>**Unknown**
  Staging app...
  ____________________________
  </code></pre>
  <p>and a toast over it saying:</p>
  <pre><code>   There was a problem parsing the package.
  
                      OK.
  </code></pre>
  <p>Yet, I can install the <code>ave.apk</code> normally through Android Studio and also by <code>adb install ave.apk</code>. Even with the app itself, as long as I don't save the apk in the app folder!</p>
  <p>I see this error in Android Studio console:</p>
  <pre><code>2021-04-23 11:56:15.350 3917-3971/? I/[AirCmd]_MediaControlStateMonitor: isForegroundAppSupportsMediaButton : mediaSession is empty
  2021-04-23 11:56:15.350 3917-3971/? I/[AirCmd]_MediaControlStateMonitor: active Notification List is null
  2021-04-23 11:56:15.350 3917-3971/? I/[AirCmd]_PenActionRule: getAction : get default action data from remote action because pen action data is null.
  2021-04-23 11:56:15.350 3917-3971/? I/[AirCmd]_BleSpenButtonActionDetector: enableDoubleClickDetection: enabled=true, doubleClickWaitInterval=300
  2021-04-23 11:56:15.350 3917-3971/? I/[AirCmd]_RemoteSpenMainController: onSwitch : package is com.google.android.packageinstaller   and activity is com.android.packageinstaller.InstallStaging and isBleConnected is true and hasActions is false
  2021-04-23 11:56:15.350 3917-3917/? I/AC:FloatingIconController: onBleFloatingIconStateChanged isEnabled : false, delay : 250
  2021-04-23 11:56:15.351 2661-28003/? W/FuseDaemon: Invalid other package file access from com.floritfoto.apps.ave(: /storage/58ED-1620/Android/data/com.floritfoto.apps.ave/ornitologia/Downloads/ave.apk: Success
  2021-04-23 11:56:15.352 11973-16410/? W/InstallStaging: Error staging apk from content URI
      java.io.IOException: read failed: ENOENT (No such file or directory)
          at libcore.io.IoBridge.read(IoBridge.java:519)
          at java.io.FileInputStream.read(FileInputStream.java:320)
          at android.os.ParcelFileDescriptor$AutoCloseInputStream.read(ParcelFileDescriptor.java:1005)
          at java.io.FileInputStream.read(FileInputStream.java:289)
          at android.os.ParcelFileDescriptor$AutoCloseInputStream.read(ParcelFileDescriptor.java:996)
          at com.android.packageinstaller.InstallStaging$StagingAsyncTask.doInBackground(InstallStaging.java:184)
          at com.android.packageinstaller.InstallStaging$StagingAsyncTask.doInBackground(InstallStaging.java:167)
          at android.os.AsyncTask$3.call(AsyncTask.java:394)
          at java.util.concurrent.FutureTask.run(FutureTask.java:266)
          at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:305)
          at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
          at java.lang.Thread.run(Thread.java:923)
       Caused by: android.system.ErrnoException: read failed: ENOENT (No such file or directory)
          at libcore.io.Linux.readBytes(Native Method)
          at libcore.io.Linux.read(Linux.java:189)
          at libcore.io.ForwardingOs.read(ForwardingOs.java:176)
          at libcore.io.BlockGuardOs.read(BlockGuardOs.java:305)
          at libcore.io.ForwardingOs.read(ForwardingOs.java:176)
          at libcore.io.IoBridge.read(IoBridge.java:509)
          at java.io.FileInputStream.read(FileInputStream.java:320) 
          at android.os.ParcelFileDescriptor$AutoCloseInputStream.read(ParcelFileDescriptor.java:1005) 
          at java.io.FileInputStream.read(FileInputStream.java:289) 
          at android.os.ParcelFileDescriptor$AutoCloseInputStream.read(ParcelFileDescriptor.java:996) 
          at com.android.packageinstaller.InstallStaging$StagingAsyncTask.doInBackground(InstallStaging.java:184) 
          at com.android.packageinstaller.InstallStaging$StagingAsyncTask.doInBackground(InstallStaging.java:167) 
          at android.os.AsyncTask$3.call(AsyncTask.java:394) 
          at java.util.concurrent.FutureTask.run(FutureTask.java:266) 
          at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:305) 
          at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) 
          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) 
          at java.lang.Thread.run(Thread.java:923) 
  2021-04-23 11:56:15.353 11973-11973/? I/Dialog: mIsSamsungBasicInteraction = false, isMetaDataInActivity = false
  2021-04-23 11:56:15.354 11973-11973/? I/DecorView: [INFO] isPopOver=false, config=false
  2021-04-23 11:56:15.354 11973-11973/? I/DecorView: updateCaptionType &gt;&gt; DecorView@2e1b4ce[], isFloating=true, isApplication=true, hasWindowDecorCaption=false, hasWindowControllerCallback=false
  2021-04-23 11:56:15.354 11973-11973/? D/DecorView: setCaptionType = 0, this = DecorView@2e1b4ce[]
  2021-04-23 11:56:15.357 11973-11973/? D/ScrollView: initGoToTop
  2021-04-23 11:56:15.358 11973-11973/? D/ScrollView: initGoToTop
  </code></pre>
  <p>So it seems some file has vanished?? Which one? With the two popups being shown, I can still do a</p>
  <pre><code>ls /storage/58ED-1620/Android/data/com.floritfoto.apps.ave/ornitologia/Downloads/ave.apk
  </code></pre>
  <p>and <code>ave.apk</code> is there. So it is not the <code>ave.apk</code> that is missing. Unfortunately, Android does not tell me WHICH file is not found...</p>
  <p>This is the URI that I get from the file provider:</p>
  <pre><code>content://com.floritfoto.apps.ave.provider/root/storage/58ED-1620/Android/data/com.floritfoto.apps.ave/ornitologia/Downloads/ave.apk
  </code></pre>
  <p>This is the content of my xml path file:</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;paths&gt;
      &lt;external-path
          name=&quot;external_files&quot;
          path=&quot;.&quot; /&gt;
      &lt;root-path
          name=&quot;root&quot;
          path=&quot;.&quot; /&gt;
  &lt;/paths&gt;
  </code></pre>
  <p><strong>EDIT:</strong> If I save the apk into the internal memory, or anywhere else in the sdcard, I can update. So this is something related to the app folder.</p>