Reputation: 335
I am working on an Apache Cordova app that gets stuck trying to load a map. It works in android 4.2.2 but not working on more recent versions 7.0.0/7.1.1.
I try to call it from my index.html file with the next line:
<script type="text/javascript" src="http://api.cercalia.com/api/cercalia.js?key=[key]&theme=red"></script>
Also I created a test file within my JS folder with the code from the API online and it works perfectly.
I suspect that the whitelist
plugin might not be working properly.
Any ideas on how to tackle this?
Upvotes: 1
Views: 2702
Reputation: 51
You need to Internet Permission
Go to app -> src -> main -> AndroidManifest.xml.
Add following code
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.java2blog.helloworldapp">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".HelloWorldActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
Upvotes: 1
Reputation: 22166
OK so I found the problem.
window.cordova.plugins
was undefined. This was a standard or common place to put plugins in previous cordova versions but didn't get defined in corvoda 7.
I found this line of code was causing the issue:
if (window.cordova && window.cordova.plugins.firebase && window.cordova.plugins.firebase.analytics) {
I have no idea why this was showing a -
in the error message!
Upvotes: 0
Reputation: 335
Apparently I just had to add the next meta tag on the index.html
head:
<meta http-equiv="Content-Security-Policy" content="default-src *; script-src 'self' 'unsafe-inline' 'unsafe-eval' *; style-src 'self' 'unsafe-inline' *">
This will load the map correctly.
Upvotes: 2