I'm creating a Phonegap Android app and I'm having trouble when adding a plugin to it. Cordova version is 2.2.0. I'm not using jQM or Sencha Touch. I test the app on Android 4.0.
The plugin I refer to is Android Phonegap plugin. This is my index.html
file:
<!DOCTYPE html>
<html>
<head>
...
</head>
<body>
<div class="wrapper">
...
</div>
<script type="text/javascript" src="vendor/cordova-2.2.0.js"></script>
<script type="text/javascript" src="assets/application.js"></script>
<script type="text/javascript" src="js/index.js"></script>
<script type="text/javascript" src="js/datePickerPlugin.js"></script>
</body>
</html>
This is my main Java file:
import android.app.Activity;
import android.os.Bundle;
import org.apache.cordova.*;
public class looker extends DroidGap
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
super.setIntegerProperty("splashscreen", R.drawable.splash);
super.loadUrl("file:///android_asset/www/index.html", 7000);
}
}
So in order to understand if the problem is within the plugin, I minimized this file in assets/application.js
where all my minimized scripts I use are. I removed the script tag for the plugin from index.html
and the plugin was working just fine! So it's got something to do with the URL's maybe?
What have I tried so far?
I was researching a lot and tried several solutions to other similar problems.
Made sure I have 3 /'s for the loadUrl
in my main class:
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
super.setIntegerProperty("splashscreen", R.drawable.splash);
super.loadUrl("file:///android_asset/www/index.html", 7000);
}
Had that from the very beginning, didn't make any difference.
Tried calling super.init() before super.loadUrl(). Didn't work as well.
Tried this:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.init();
super.setIntegerProperty("loadUrlTimeoutValue", 6000);
super.loadUrl("file:///android_asset/www/index.html");
}
Still not fixing the problem.
Checked if the file is loaded in the app, by adding an alert();
. It loads.
That's in general. Will be glad to provide you with additional info if needed in order to resolve this issue. Thanks in advance!
I followed the guide and was able to get the plugin working just fine.
However, I was able to replicate the "Unknown chromium error: -6" when I had this in my config.xml:
<plugin name="DatePickerPlugin1" value="com.phonegap.plugin.DatePickerPlugin"/>
Make sure that the "name" attribute in the XML is DatePickerPlugin, since that is the name that the JavaScript code uses for the plugin: https://github.com/phonegap/phonegap-plugins/blob/master/Android/DatePicker/datePickerPlugin.js#L33
There may be other ways to generate the same error though. If this doesn't help, can you post or link to your HTML file that actually calls out to this plugin, as well as your config.xml? (Make sure you are using a res/xml/config.xml and not res/xml/plugins.xml which has been deprecated here: http://cordova.apache.org/docs/en/2.0.0/guide_upgrading_android_index.md.html#Upgrading%20Cordova%20Android
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With