I am trying to implement an auto-update for our in-house app by downloading the new versions directly from a database on our server and installing it.
I am getting the error "There was a problem parsing the package". There seems to be a number of suggestions on the web. I have made sure that:
The Version # of the apk to be installed is greater than the currently installed package.
The package name is the same.
The package SDK target is the same.
Install, Delete and Reboot packages permissions enabled.
Device definately supports the SDK target.
My last idea is a corrupted file.. so I'm not sure if I am uploading/downloading to/from the server correctly.
To upload to the server I am using:
Dim fInfo As New FileInfo(_filePath)
Dim numBytes As Long = fInfo.Length
Dim fStream As New FileStream(_filePath, FileMode.Open, FileAccess.Read)
Dim reader As New BinaryReader(fStream)
Dim data As Byte() = reader.ReadBytes(CInt(numBytes))
Dim fileSize As Long = data.Length
Where I am saving 'data' into a varbinary(max) field.
To download and run using Xamarin, I am using:
// Download file from server
Console.WriteLine("Downloading new APK"); byte latestAPK = _API.GetLatestApk (Sync._ApiKey, ApplicationPreferences.Email, ApplicationPreferences.Password, _ReleaseName, _ReleaseKey); File.WriteAllBytes (_Path + _PackageName, latestAPK); Console.WriteLine("Downloaded new APK"); // Run the software to perform update Intent i = new Intent (Intent.ActionView); i.SetDataAndType (Android.Net.Uri.FromFile(new Java.IO.File(_Path + _PackageName)), "application/vnd.android.package-archive"); i.AddFlags (ActivityFlags.NewTask); context.StartActivity (i);
Please help! I'm pulling my hair out here