Executing the Phonegap build command will include the cordova.js file

In my development process of a Phonegap Build application, I encountered an issue with the android file. Every time I compile the zip file, the resulting APK always ends up containing three javascript files: phonegap.js, cordova.js ...all of which have identical content. What steps can I take to eliminate the unnecessary duplicate js files and optimize my application?

Answer №1

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.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Handlebars If the length of variable is more than

I'm currently working on creating email templates using Foundation email and Handlebars. My goal is to display certain headings based on the data passed to the component, but I haven't been successful so far. Can you help me identify what I am do ...

Create a JavaScript function to calculate a 2-tailed t distribution by adapting an already existing method

Can someone help me with implementing a two-tailed t-test in JavaScript? Resource: Student's t distribution in JavaScript for Google Spreadsheet I have taken a potential solution from the link and customized it to function outside of the form: func ...

Troubleshooting CORS Problems with jQuery and Spring Boot

Recently, I have encountered an issue with my front-end pages that are developed using jQuery 3.2.1 and running by npm. Here is a snippet of how it is set up: "start": "http-server -a localhost -p 8000 -P http://localhost:8080 -c-1 --cors ./app" When mak ...

Discovering the world of Promises in TypeScript and understanding how to return specific types

Transitioning from coding in Clojure for the past two years to TypeScript has been an interesting journey. However, I've hit a bit of a roadblock today. The issue lies with my interface: interface ICustomer { id: number, first_name: string } I ...

Steps for inserting an additional header in an Angular table

https://i.stack.imgur.com/6JI4p.png I am looking to insert an additional column above the existing ones with a colspan of 4, and it needs to remain fixed like a header column. Here is the code snippet: <div class="example-container mat-elevation-z8"> ...

Alert: Are functions not considered legitimate as a React child due to the presence of my container?

I am receiving an intriguing warning message in my console. The warning message states: Warning: Functions are not valid as a React child. This may occur if you return a Component instead of from the render. Or perhaps you meant to call this function rath ...

Creating a button that allows users to quickly navigate back to the top of a webpage

On my website, I have a convenient "back to top" feature that allows users to easily navigate back to the top of the page: If you scroll down the page, you'll see this feature in action. This particular feature is part of the theme I'm using on ...

Using arrays as props in React with Typescript

In my code, I have a Navbar component that contains a NavDropdown component. I want to pass an array as a prop to the NavDropdown component in order to display its dropdown items. The array will be structured like this: DropDownItems: [ { ...

Changing the structure of elements in an array using JavaScript

I am seeking a way to convert an array of strings, which represent dates in the format of 201001 ,201002, into something more readable like 2010 January, 2010 February. Do you have any suggestions on how to achieve this? var Array = ["201005", "201006", " ...

Launching the server with a custom path in Nuxt.js: Step-by-step guide

My Nuxt.js application has several nested routes. . ├── index │   ├── _choice │   │   ├── city │   │   │   ├── index.vue │   │   │   ├── _zipCode │   │   │   │   ├── i ...

Can you explain the variances between ngx-translate and ngx-i18next for me?

As ngx-i18next serves as a wrapper for i18next, I am curious about the specific differences in translation capabilities between ngx-translate and i18next. ...

What is the process for accepting user input if their username remains the same?

I've been grappling with what logic to implement in this scenario. I want the user to be able to update their information, but an issue has arisen. What if a user wishes to change their email but keep the same username? As it stands, the username is ...

"An unexpected result was received from an AJAX get request

In my current project using Laravel, I have implemented AJAX to pass the value of a textbox. However, I am facing an issue where it always passes 'R' regardless of the variable passed with AJAX. Below is my code: <div class="form-group"> ...

Analyzing an array of objects

Is there a way to filter an array of objects to only include elements that have 'text' containing 'ild'? For example, consider the following array: public data: any[] = [ { treeViewKey:0, id: 1, text: 'Root Node 1&a ...

AngularJS: The dynamic setting for the stylesheet link tag initiates the request prematurely

I'm encountering a problem that is somewhat similar (although not exactly the same, so please be patient) to the one discussed in Conditionally-rendering css in html head I am dynamically loading a stylesheet using a scope variable defined at the sta ...

What is the process for configuring browser environment variables in Next.js with the `"type": "module"` setting?

While working on my nextjs project, I have encountered an issue with setting environment variables that can be accessed at the browser level. Whenever I use console.log(process.env), it always returns {} in the javascript console, and any variable like pr ...

Leveraging Angular services prior to manual bootstrapping

Is it possible to access angular services without calling angular.bootstrap on an empty div prior to manually bootstrapping when the ng-app directive is not being used? While the following method does work, I am interested in finding a more direct solutio ...

Manipulating attributes in HTML using jQuery which are stored in a variable

Generating dynamic inputs with unique names is my current requirement. Initially, I store the html template content in a variable: var template = $("#question_template").html(); Next, to differentiate each set of added input blocks, I include an index: ...

Error: Unable to locate module - The specified file cannot be resolved when utilizing an external JavaScript library

I am currently integrating a WYSIWYG editor (TUI Editor) into my Angular2+ application. Since there is no official Angular wrapper available, I have decided to create my own based on an existing wrapper. Due to some installation issues with npm, I saved t ...

Stopping a NodeJs file running on an Ubuntu server

After enlisting help to install a Js script on my server, I encountered an issue where changes I made to the scripts/files were not reflected in the browser. After scouring the internet for answers for about 24 hours, I discovered that Js scripts need to b ...