Reputation: 3
Hi this is my first post but I've been trying to use the Screenshot plugin from here: https://github.com/phonegap/phonegap-plugins/tree/88a57e1c232f604f73be5bd82868d711ac235424/Android/Screenshot
And I get this error: Uncaught TypeError: Cannot call method 'SaveScreenshot' of undefined at file ... And I really dont know why it's throwing me an error!! Any help will be welcome
Here is the JS that is calling the method:
document.addEventListener("deviceready", onDeviceReady, false);
// PhoneGap is ready
//
function onDeviceReady() {
$('#saveBtn').click(function(){
window.plugins.Screenshot.saveScreenshot();
});
}
And here is the html for the button
<button id="saveBtn">Save</button><br>
I have sourced the Screenshot.js file and everything
EDIT: I am using Cordova 2.0.0 if that helps and I'm using the plugin Screenshot that was coded for the same version of Cordova
Upvotes: 0
Views: 1012
Reputation: 1114
I also faced same problem. Here I am explaining the problem causes for me. Goto your plugin config.xml and see whether the directory paths are correct or not.
<js-module src="www/hello.js" name="hello">
<clobbers target="cordova.plugins.hello" />
<config-file target="res/xml/config.xml" parent="/*">
<feature name="Hello">
<param name="android-package" value="com.example.hello.Hello"/>
</feature>
</config-file>
<source-file src="src/android/Hello.java" target-dir="src/com/example/hello"/>
Be specific about paths. Sometimes it kills our time .
Upvotes: 0
Reputation: 7333
try:
window.plugins.screenshot.saveScreenshot();
From the source code windows.plugins.screenshot
appears to be in all lower case characters:
if (!window.plugins.screenshot) {
window.plugins.screenshot = cordova.require("cordova/plugin/screenshot");
}
Upvotes: 1