Reputation:
currently i am working with the Android's APK expansion files. By using the sample code provided by Google, It downloads the file and save on the device but gives CRC error. Any help will be appreciated.
Upvotes: 4
Views: 2151
Reputation: 86
The Google sample code performs the CRC32 algorithm on each file's raw data in the zip file, and compares this with the value stored in the zip file for verification purposes. Sadly, the zip format specifies that the stored CRCs are for the files once uncompressed. If your zip file is compressed, therefore, the CRCs will fail to match, if left uncompressed they match fine. This has been submitted to Google as a bug.
You could work around the problem by not compressing your zip file, but that seems like a bad idea for what is already a fairly large download. Personally, I have replaced this algorithm completely in my project. Instead, I generate a CRC for the zip file as a whole, and cache this value inside my installer apk as a build step, then compare it at the same time as in the sample code.
Upvotes: 2