When uploading an .apk file to Amazon Appstore, occasionally you might see an error message: "Failed to upload binary. The binary appears to be corrupted. Please check the binary and upload again."
1. That error can be displayed when the .apk file was unpacked/repacked or otherwise modified where it no longer has a correct structure required for an Android application package (APK) file. However, assuming you haven’t tampered with the file after your build system produced the binary, the possibility of that is usually remote.
To troubleshoot this issue, the first thing to check is the developer toolchain and the build process you are using. Some 3rd party dev tools (such as Appcelerator Titanium or similar) that are used to generate your binary might be the culprit, because of the problems either in JDK or ZIP related modules in Python or Perl that some of those tools might be using. The quick solution to this would be to manually unpack the .apk file and then repack it back using standard ZIP tools (for example on Windows that would be either WinZip or even the natively built in ZIP functionality in the OS). After that try to re-upload your binary in the Dev Portal, and hopefully it will go through without any errors.
For reference, please see these two threads seem to indicate a bug in the corresponding Perl and Python modules to zip a file:
On a related note, there is also a Java issue that could impact this:
This appears to be a JDK bug that supposedly has been fixed in JDK9. The bug is an error where the zip file that is initially created has the optional signature. Another tool (like Python) reads the zip file and preserves the 0x08 flag byte, but when outputting the zip file does not include the optional (but recommended) data descriptor signatures. The workaround for this, as described above, is to unzip and re-zip the file yourself / manually, and then try to upload it again.
2. If re-packing the binary did not solve the problem, the culprit could be the manifest. It is likely it contains invalid entries. For example, the manifest file may contains the <uses-amzn-sdk> element with an unparseable value minAmznSdkVersion: null, targetAmznSdkVersion: null, maxAmznSdkVersion: null.
This is not allowed as per our apk parser. If <uses-amzn-sdk> is present then it is expected to have values for the above elements in it. Please look through your Android manifest file, make sure all entries are valid, and there are no duplicate entries, for example more than 1 entry for <uses-amzn-sdk android:minSdkVersion="3"/>, etc.
Please fix the manifest, making sure it’s valid, and resubmit your app. Here is the documentation:
If the issue persists, please login to your Dev Portal account, click the ‘Contact Us’ link and provide full details of how you build and sign your app and what tools and SDKs you use.
Keywords: binary upload, corrupted binary