Download And Install App Programmatically

Thread Starter

Rank:

None

Points:

Posts:

Joined:

Sep 13, 2017

I'm currently working on an application that has been built so that it can manage upgrading and downgrading of versions away from the Play Store using my company's web servers. This worked fine until we tried compiling against Nougat.

Process: com.google.android.packageinstaller, PID: 3807
java.lang.RuntimeException: An error occurred while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:318)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)
at java.util.concurrent.FutureTask.setException(FutureTask.java:223)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:243)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:761)
Caused by: java.lang.SecurityException: Permission Denial: opening provider android.support.v4.content.FileProvider from ProcessRecord{d42d519 3807:com.google.android.packageinstaller/u0a17} (pid=3807, uid=10017) that is not exported from uid 10085
at android.os.Parcel.readException(Parcel.java:1683)
at android.os.Parcel.readException(Parcel.java:1636)
at android.app.ActivityManagerProxy.getContentProvider(ActivityManagerNative.java:4169)
at android.app.ActivityThread.acquireProvider(ActivityThread.java:5434)
at android.app.ContextImpl$ApplicationContentResolver.acquireUnstableProvider(ContextImpl.java:2267)
at android.content.ContentResolver.acquireUnstableProvider(ContentResolver.java:1515)
at android.content.ContentResolver.openTypedAssetFileDescriptor(ContentResolver.java:1129)
at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:982)
at android.content.ContentResolver.openInputStream(ContentResolver.java:702)
at com.android.packageinstaller.PackageInstallerActivity$StagingAsyncTask.doInBackground(PackageInstallerActivity.java:732)
at com.android.packageinstaller.PackageInstallerActivity$StagingAsyncTask.doInBackground(PackageInstallerActivity.java:723)
at android.os.AsyncTask$2.call(AsyncTask.java:304)

Anybody got any ideas on this?

Best Answer

For anyone else that struggles with this, I've resolved the issue now! I changed the following:

Thread Starter

Rank:

None

Points:

Posts:

Joined:

Sep 13, 2017

Hi, the code I'm using is as follows: (I have just been through and added some more debug lines and the size of the file in the location I'm downloading to appears to be 0, so it could be that I'm not saving the file correctly?)

Moderator

Rank:

Points:

Posts:

Joined:

Oct 16, 2015

Yes, have you tried running your application in debug mode, and interactively debugging it by using breakpoints and stepping through the code.
If you don't know how to do this, please read the following thread as a starting point:

Rank:

None

Points:

Posts:

Joined:

Feb 6, 2018

Hello, thank you very much for the contributions, they have been very helpful. For me it works well the download, but when executing startActivity, I get a window that asks me to "open with", where it gives me several options of applications, how to avoid this?