Reputation: 3481
I have created a project with the "Tools for Apache Cordova" in VS Community 2013.
I then installed the BrodySoft SQLitePlugin (com.brodysoft.sqlitePlugin)
How do I reference the SQLitePlugin.js in the index.html file?
I tried this:
<script type="text/javascript" src="SQLitePlugin.js"></script>
When I run in ripple emulator, I get this error report in the console:
Failed to load resource: the server responded with a status of 404 (Not Found) File: SQLitePlugin.js, Line: 0, Column: 0
What is the correct way to reference the js file?
Thanks
Upvotes: 2
Views: 3983
Reputation: 804
I've faced same problem and i solved rebuilding the project.
The problem, afaik, is that when you build with ripple, if you add a plugin after you've previously built your solution, it may be unnoticed and the build doesn't regenerate cordova_plugins.js (i experienced this by myself) so whenever you add a plugin, instead of just Build, do a Rebuild or clean the solution and compile again
this way i solved any problem i had with unreferenced js (and i confirm that you don't need to reference a plugin .js once it has been added to your project using the config.xml editor
Upvotes: 0
Reputation: 63
I have recently just finished building a app using VS Cordova tools and use a number of plugins which need to be referenced in the config.xml file and I wasn't required to reference them in them in the index.html file.
Also this does not require the plugin to be installed as mentioned in Victor Sosa answer the plugin will be included when the app is built like cordova.js.
To do this view the config.xml in code view and add the following inside the widget tags:
<vs:plugin name="com.brodysoft.sqlitePlugin" version="1.0.3" />
(I believe the current version is correct)
I would also uninstall the SqlitePlugin plugin as this may cause issues when trying to build the app.
I hope this solves your issue.
Upvotes: 0
Reputation: 398
I'm not familiar with VS, but I presume it uses the same approach as any Cordova application.
In Cordova, when you install a plugin you don't need to declare a <script>
element referencing to the JS in such plugin, instead it gets automagically copied on the cordova.js script which is generated at build time. What you need to do is to make sure you declare a <script src="cordova.js">
tag in your HTML in order to use the Cordova functionality as well as the plugins.
Make sure you are following recommendations documented in the plugin by the author
https://github.com/brodysoft/Cordova-SQLitePlugin
As for the ripple emulator, I have never been successful with it. In fact, my experience with it is awful. My advice is that you use the actual platforms you are targeting to, Windows, Android, iOS, etc. Either emulator or actual device will work way better than Ripple.
Upvotes: 3