PhoneGap/Cordova-built android application fails to display external links

I'm currently developing a geolocation app and encountering an issue with loading a Google map. The native geolocation is functioning properly, but incorporating the map has been challenging, similar to the example shown in Simple Markers here.

After discovering that external domains need to be whitelisted, I added specific access origins to my config.xml within the root of the PhoneGap application:

<access origin="*" />
<access origin="*://*.googleapis.com/*" subdomains="true" />
<access origin="*://*.gstatic.com/*" subdomains="true" />
<access origin="*://*.google.com/*" subdomains="true" />
<access origin="*://*.googleusercontent.com/*" subdomains="true" />

Even after applying these changes under <platform name="android"> and later removing them, the map still fails to load.

In an attempt to troubleshoot, I substituted the map with a simple image. The HTML component now looks like this:

<body>
    <span><img src="https://maps.gstatic.com/mapfiles/api-3/images/spotlight-poi_hdpi.png" alt="" /></span>
    <div id="map"></div>
</body>

The image displays correctly when opened in a browser:

https://i.sstatic.net/hI5XM.png

However, upon compiling and running the app on my tablet, the image fails to render as seen here:

https://i.sstatic.net/gcnLy.png

This suggests that there may be issues with the access permissions not being configured correctly. The image is broken, googleapis.com doesn't load, and the map remains inaccessible.

If needed, you can view my complete config.xml file on Pastebin here.

I am seeking assistance in resolving why the Android app is rejecting external URLs within the context of PhoneGap/Cordova.

I suspect it could be related to some obscure permission setting that I'm unaware of. Any help would be greatly appreciated as I've hit a roadblock. Thank you in advance.

Answer №1

If you've allowed * as an origin, there's no need for the Google ones. Try checking the app through Chrome by going to chrome://inspect on your desktop browser. You can inspect the app from there as long as the device is connected to your computer.

The console in the inspector will display any errors from your requests. It seems likely that a Content Security Policy is blocking the request. Consult the latest version of the whitelist documentation at https://github.com/apache/cordova-plugin-whitelist. Towards the end of the readme, you'll find some examples of a Content Security Policy. I recommend adding the code snippet below to your index.html file:

<meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com; style-src 'self' 'unsafe-inline'; media-src *" >

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

I would greatly appreciate any recommendations on how to troubleshoot and

I've been working on the "Map the Debris" challenge at freecodecamp, and I'm facing an issue. While my code works fine in my PC's editor, it doesn't satisfy the conditions when I paste it into the website area. Any suggestions on how t ...

Manipulate sibling elements using jQuery's addClass and remove methods

I have implemented a function that adds the class active to elements when they reach the top of the browser, ensuring that the next element will scroll in over the top. While this works smoothly in Chrome, I am encountering some jumping behavior when testi ...

Ways to pinpoint a live application using a KeyEvent?

My main objective is to use a key event to target a specific application that is running, whether in the foreground or background, from a background service. I have experimented with various solutions but so far have been unsuccessful. The few methods I ...

Struggling to access the ref object of a Child Component in React JS parent component

I need to access properties like getBoundingClientRect() and scrollTop from the <div> and <span> components in the ChildComponent, but I want to do it in the Parent component. Here's how I attempted it: class Parent extends Component { ...

Transforming JSON arrays from a server API request into Retrofit2 objects

I manage a server that gathers a list of topics from a forum through a query. The data fetched using curl appears in the following format - [ { "id": 728, "date": "2016-01-01T13:01:51", "date_gmt": "2016-01-01T07:31:51", .... }, { ...

What is the best way to bring a module into an Angular project?

I have a project in Angular with an additional module created as an npm package. The structure of the module is as follows: --otherModule --other-module.module.ts --index.ts --package.json index.ts: export { OtherModule } from './other-module ...

Use JavaScript to sift through an array and exclusively retrieve items that match a specific value

I am working with an array of objects that contain a phase key, and I want to filter out only the ones that have a specific phase value. Additionally, I need to map some other key/value pairs into the final return. Here is my current code: phaseToBlocks ( ...

What causes TypeScript to automatically infer a default property when dynamically importing a JavaScript file that lacks a default export?

While dynamically importing a javascript file that exports multiple functions (without a default export), I encountered this issue: const sayHi = import('./sayHi.js') I was expecting the type of sayHi to be Promise<{name1: function, name2: fu ...

I am currently having issues with the mustache syntax in vuejs, as it is not functioning properly

Having an issue with Vue.js where the mustache syntax isn't working properly. <!DOCTYPE html> <html> <head> <title>index</title> <script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cg ...

Guide on generating a request through iteration using Javascript

I'm currently working on a request that involves multiple methods, and I want to streamline the code by using an enum to iterate through and construct the request. However, my attempt at doing this has resulted in unexpected outcomes. The original co ...

Turn off choices by utilizing data type attribute values within select2 version 4

I'm attempting to deactivate the options by using the data-type attribute specified for each option in select2. Unfortunately, my attempts have been unsuccessful thus far. In addition, I am encountering this error within the change event handler: ...

Is it possible to utilize Jquery in order to add an opening <tr> tag and a closing </tr> tag within a dynamic table?

I have been experimenting with the code snippet below in an attempt to dynamically add a closing </tr> tag followed by an opening tag after every three cells, essentially creating a new row. Progress has been made as the DOM inspector shows a TR nod ...

The mobile navigation in HTML has a slight issue with the ::after pseudo-element, specifically within the

As I prepare to launch my website, I have made adjustments to the mobile layout by moving the navigation links to a navigation drawer. The template I am using included JavaScript scripts to handle this navigation change. However, I encountered an issue whe ...

Utilizing Cookies within an HTML Page

My current code is functioning perfectly, accurately calculating the yearly income based on the input "textmoney." I have a link to a more advanced calculator for a precise prediction. My goal is to find a way for the website to retain the data input from ...

The onClick action kicks in as soon as the page finishes loading

One particular line of code in the Button Tag has caught my attention. let content = this.props.searchResult.map((ele, i) => { let card_id = ele.user.username + "_card"; return( <div className="col s12 m6 l4" key={i} id={card_id}> ...

Sluggish Performance Noticed with Angular's Ng-If Directive

I have a scenario where I am using an ng-if directive to hide an element until a specific condition is met. Despite the condition being met in my controller, the element does not seem to be in the DOM when I try to locate it with a jQuery selector. It seem ...

A critical issue occurred: array length is invalid. The attempt to include EJS in the template failed due to

Currently, I am attempting to loop through my JSON data using EJS from Node/Express. However, I need to insert a different pin into the flexbox when it reaches the 6th iteration. Whenever I try to implement this logic, I encounter a severe error that disr ...

After npm installation and running the dev command, an error is displayed in the console, despite the project functioning properly on a different

After successfully installing a reliable project on my personal computer and compiling it without any issues, I encountered an error message in the console. Uncaught ReferenceError: regeneratorRuntime is not defined at eval (index.umd.js?e3f3:5) at eval ( ...

Experience the smooth transition effects of sliding down the login box when hovering over an image or div

Is there a way to switch the hover js transition effect to a different transition type like fadeIn, fadeOut, or simple transitions? Check out this link for more details. Here is an example of the HTML code: <img id="login-trigger" src="http://www.join ...

Problem with Angular2, NodeJS, and Passport Integration

At the moment, my Angular2 front-end is running on localhost:3000 while the NodeJS back-end (using KrakenJS) is running on localhost:8000. When I input the credentials and make a call to the this.http.post('http://localhost:8000/login', body, { h ...