locked
Stuck on running downloaded APK -There was a problem parsing the package RRS feed

  • Question

  • User447 posted

    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 :(

    Wednesday, June 19, 2013 9:45 AM

All replies

  • User209 posted

    This doesn't make sense. You are using VB.Net code to get the APK?

    Wednesday, June 19, 2013 10:09 AM
  • User447 posted

    No, I'm using vb.net code to upload the APK to my database, then C#.net to download it as a SOAP byte array.

    I wanted to give code for both ends.. although I have since verified that corruption is not the issue anyway.

    Wednesday, June 19, 2013 10:57 AM
  • User447 posted

    Ok, I've found the issue in the logs, but no idea why it's getting a permission denied.

    06-19 11:52:45.426 W/ActivityManager(  486): Activity pause timeout for ActivityRecord{424b6658 u0 ttt.ttt/tablettimeclock.MainActivity}
    06-19 11:52:45.446 I/ActivityManager(  486): Start proc com.android.packageinstaller for activity com.android.packageinstaller/.PackageInstallerActivity: pid=1281 uid=10044 gids={50044, 1028}
    06-19 11:52:45.466 D/dalvikvm(  131): GC_EXPLICIT freed 40K, 3% free 7279K/7464K, paused 2ms+3ms, total 27ms
    06-19 11:52:45.486 D/dalvikvm(  131): GC_EXPLICIT freed <1K, 3% free 7279K/7464K, paused 2ms+3ms, total 22ms
    06-19 11:52:45.486 W/zipro   ( 1281): Unable to open zip '/data/user/0/ttt.ttt/files/ttt.apk': Permission denied
    06-19 11:52:45.486 D/asset   ( 1281): failed to open Zip archive '/data/user/0/ttt.ttt/files/ttt.apk'
    06-19 11:52:45.486 W/PackageInstaller( 1281): Parse error when parsing manifest. Discontinuing installation
    06-19 11:52:45.486 W/PackageParser( 1281): Unable to read AndroidManifest.xml of /data/user/0/ttt.ttt/files/ttt.apk
    06-19 11:52:45.486 W/PackageParser( 1281): java.io.FileNotFoundException: AndroidManifest.xml
    06-19 11:52:45.486 W/PackageParser( 1281):  at android.content.res.AssetManager.openXmlAssetNative(Native Method)
    06-19 11:52:45.486 W/PackageParser( 1281):  at android.content.res.AssetManager.openXmlBlockAsset(AssetManager.java:487)
    06-19 11:52:45.486 W/PackageParser( 1281):  at android.content.res.AssetManager.openXmlResourceParser(AssetManager.java:455)
    06-19 11:52:45.486 W/PackageParser( 1281):  at android.content.pm.PackageParser.parsePackage(PackageParser.java:509)
    06-19 11:52:45.486 W/PackageParser( 1281):  at com.android.packageinstaller.PackageUtil.getPackageInfo(PackageUtil.java:73)
    06-19 11:52:45.486 W/PackageParser( 1281):  at com.android.packageinstaller.PackageInstallerActivity.onCreate(PackageInstallerActivity.java:511)
    06-19 11:52:45.486 W/PackageParser( 1281):  at android.app.Activity.performCreate(Activity.java:5104)
    06-19 11:52:45.486 W/PackageParser( 1281):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
    06-19 11:52:45.486 W/PackageParser( 1281):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
    06-19 11:52:45.486 W/PackageParser( 1281):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
    06-19 11:52:45.486 W/PackageParser( 1281):  at android.app.ActivityThread.access$600(ActivityThread.java:141)
    06-19 11:52:45.486 W/PackageParser( 1281):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
    06-19 11:52:45.486 W/PackageParser( 1281):  at android.os.Handler.dispatchMessage(Handler.java:99)
    06-19 11:52:45.486 W/PackageParser( 1281):  at android.os.Looper.loop(Looper.java:137)
    06-19 11:52:45.486 W/PackageParser( 1281):  at android.app.ActivityThread.main(ActivityThread.java:5041)
    06-19 11:52:45.486 W/PackageParser( 1281):  at java.lang.reflect.Method.invokeNative(Native Method)
    06-19 11:52:45.486 W/PackageParser( 1281):  at java.lang.reflect.Method.invoke(Method.java:511)
    06-19 11:52:45.486 W/PackageParser( 1281):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
    06-19 11:52:45.486 W/PackageParser( 1281):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
    06-19 11:52:45.486 W/PackageParser( 1281):  at dalvik.system.NativeStart.main(Native Method)
    

    The device is rooted so it should work shouldn't it?

    Wednesday, June 19, 2013 11:56 AM
  • User209 posted

    Have you set the INSTALL_PACKAGES permission in your AndroidManifest.xml?

    Wednesday, June 19, 2013 12:13 PM
  • User447 posted

    Yep. I've set Delete packages, Install packages and Restart packages!

    Wednesday, June 19, 2013 12:33 PM
  • User447 posted

    I figured it out. You need to save the APK to a public directory.

    For example:

    public static String _Path = Android.OS.Environment.GetExternalStoragePublicDirectory(Android.OS.Environment.DirectoryDownloads).ToString();

    Friday, June 21, 2013 2:21 PM
  • User24558 posted

    Hi @Le-royStaines.7824 , I was having same issue and realized that it was due to permissions, but I was not able to find a folder were to put my downloaded file, you saved me! thanks!

    Friday, May 29, 2015 11:41 AM
  • User298483 posted

    I don't see any thread or asynctask there. Are you download it from the main UI?

    Wednesday, February 8, 2017 6:44 PM
  • User183364 posted

    @"Le-royStaines.7824" Install the Signed apk in your android device.

    Thursday, February 9, 2017 6:37 AM