Just a heads up, the extra files in your APK are actually intentionally included to prevent confusion among users as per developer recommendations:
It was discovered that many users were adding the wrong file to their projects. Including any of the mentioned files helped avoid misunderstanding, which was deemed more important than having two additional files present.
With PhoneGap 2.8 now featuring cordova.js
without the version number, there's an ongoing discussion about removing these extra files mentioned in this GitHub issue:
An update is being considered to eliminate redundant .js files now that PhoneGap 2.8 has introduced cordova.js without the version number.
However, if you're not keen on waiting for this change and want to take matters into your own hands, here's how you can manually remove those files:
1. Use apktool
to unpack the APK files locally (ensure you have the Android and Java SDKs installed) - detailed instructions available here for unpacking and deletion guidance:
$ \path\to\AndroidSDK\platform-tools\apktool d myApp.apk
2. Delete the unnecessary phonegap.js
and cordova-x.x.x.js
files (only relevant for versions > 2.8.0).
3. Repackage the modified APK using apktool
:
$ \path\to\AndroidSDK\platform-tools\apktool b myApp myAppUnsigned.apk
- Note: The recompiled APK will be unsigned and cannot be deployed to devices or the Play Store without proper signing.
4. Sign the APK using your Android certificate:
Utilize jarsigner from the Java JDK along with your keystore credentials containing the key alias and password used for signing.
jarsigner -verbose -keystore ~/MySigningKey.keystore ~/Desktop/myAppUnsigned.apk myKeyAlias
Enter Passphrase for keystore:
After inputting the passphrase, the apk will be signed and ready for use.
5. Lastly, optimize the APK using zipalign before completion:
zipalign -v 4 myAppUnsigned.apk myApp.apk
By following these steps, manual removal of redundant files can be achieved. Scripting these actions can simplify the process for future builds.