I have been trying to implement an upgrade plan for my Android app which will not be released on the Android market.
The designed application work flow is as follows:
It is also important to make sure that the following tasks have been completed before the upgrade work flow will work.
I have implemented the first 3 stages of my work flow but when I try to implement the 4th part I end up getting the "Parse Error: There is an issue parsing the package" error.
Below is the offending code:
protected void upgradeApplication() {
StringBuilder urlBuilder = new StringBuilder(getString(R.string.website_ip) + "/" + getString(R.string.application_middleware) + "/" + getString(R.string.apk_folder) + "/");
File file = new File(urlBuilder.toString(), getString(R.string.apk_file));
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive");
startActivity(intent);
}
I have tested that the apk will install correctly by downloading the apk directly though the devices web browser and installing it from the downloads folder. But when I try to install from within the application I get the posted error.
"Parse Error: There is aproblem parsing the package"
Any help would be appreciated
If with this line
File file = new File(urlBuilder.toString(), getString(R.string.apk_file));
you're trying to download the file by passing the url as an argument, then it won't work. The File
constructor cannot download a file.
You should use an AsyncTask to download the apk, wait before it's done then only you can install it.