JQTouch error with phonegap - android

I'm trying to get jqtouch zepto to work with phonegap. I'm using android to test. I have the project set up and both js frameworks loading but I get this error when setting up jqtouch
TypeError: Result of expression 'a' [undefined] is not an object. at file:///android_asset/www/jqtouch.min.js:7
And this is the error for the non min js jqtouch.
TypeError: Result of expression 'hash' [undefined] is not an object. at file:///android_asset/www/jqtouch.js:420
Here is what my header and initialization of jqtouch looks like
<script src="zepto.min.js" type="text/javascript" charset="utf-8"></script>
<script src="jqtouch.js" type="text/javascript" charset="utf-8"></script>
<script src="phonegap.js" type="text/javascript"></script>
<script type="text/javascript" charset="utf-8">
$.jQTouch({
icon: 'jqtouch.png',
statusBar: 'black-translucent',
preloadImages: []
});
</script>

As I understand your question this is before you even have compiled your project. If you have just imported jqtouch.min.js and jqtouch.js and Eclipse is saying there is an error in them you can set Eclipse to ignore the file for errors.
Go to : Project->Properties->JavaScript->Include Path->Source-> Excluded Groups
ignore specific files by adding **/jqtouch*.js
This will make Eclipse ignore the supposed errors in jqtouch.js and jqtouch.min.js and make you able to compile your project.

Related

console.log not working when running an Android app in Cordova

I have a basic Cordova application with a simple console.log() function at the end.
My index.html file looks as follows:
<!DOCTYPE html>
<html>
<head>
...
</head>
<body>
...
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" src="js/index.js"></script>
<script>
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
console.log("Device is ready!");
}
</script>
</body>
</html>
As you can see it's basically the same as the automatically generated file with some console.log script at the bottom.
Unfortunately when I run the app on Android using cordova emulate android, I cannot seem to find the output from console.log(..) anywhere. However, it works fine on browsers.
console.log(..)only works on browser console, not on command line.
To get log that appears on your app use alert(...);.
Anyway if you wanted to see your logs by consol.log() you should use an IDE like Android Studio or use ddms located where your adb is installed. (run ddms.bat)
Use
cordova plugin add cordova-plugin-console
This plugin will enable console logging.
It has various methods for console printing
console.log
console.error
console.exception
console.warn
console.info
console.debug
console.assert
console.dir
console.dirxml
console.time
console.timeEnd
console.table
By default plugin is not installed so you will have to add it manually.
Reference.
Regards.

Cordova deviceReady not called on Android platform

I am trying to build a simple cordova app on iOS and Android. It worked fine on iOS. However it fails to execute on android. I am using Android Studio.
The html file still runs in android, but the addEventListener for deviceReady is not working.
This piece of code works fine in iOS but not in android:
<p id="ready" style="text-align: center">deviceready not called yet</p>
<script type="text/javascript" src="cordova-2.4.0.js"></script>
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript">
document.addEventListener("deviceready", function() {
console.log("cordova ready");
var readyElement = document.getElementById("ready");
readyElement.innerHTML = "deviceready called but not finished";
readyElement.innerHTML = "Ready";
console.log('Ready');
}, false);
</script>
I have included the both cordova-2.4.0.js and cordova.js in the project folder, but I have no idea why it doesnt connect properly.
After the page loads, the label 'device ready not called yet should be changed to device ready' , but it doesnt change in android. Can anyone suggest me the right way to do it ?
Note: 'cordova.js' is generated by the cordova in android , and 'cordova-2.4.0.js' is the one generated in iOS.
Even though I copied the iOS cordova-2.4.0.js file, it didnt worked.
Looks like I have to include only one cordova.js file generated by the cordova .
I removed the line:
<script type="text/javascript" src="cordova-2.4.0.js"></script>
and I used only:
<script type="text/javascript" src="cordova.js"></script>
and it worked.

PhoneGap project does not run on Android phone and Ripple (Error : EPERM, open .....)

I have created a new project in VisualStudio 2013, when i run it on windows emulator and device it works fine, but when I run it on Ripple and Android phones it does not run and gives me 1 Error and 1 Warning.
Warning 1 The TypeScript Compiler was given no files for compilation,
so it will skip compiling. Error 2 EPERM, open
'C:\Users\rao.burugula.cordova\lib\npm_cache\cordova-android\3.6.4\package.tgz'
When I looked for package.tgz it was a zip file so I unzipped and placed it there. but still its the same issue.
Other PhoneGap projects work fine which are created in VS2013, only the new ones I create get this error.
Could you please suggest how to resolve this issue.
Following the code which is auto generated when I create a new Blank App (Apache Cordova).
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>TestRestWebservices</title>
<!-- TestRestWebservices references -->
<link href="css/index.css" rel="stylesheet" />
</head>
<body>
<p>Hello, your application is ready!</p>
<!-- Cordova reference, this is added to your app when it's built. -->
<script src="cordova.js"></script>
<script src="scripts/platformOverrides.js"></script>
<script src="scripts/index.js"></script>
</body>
</html>
Update:
I also tried using this
The TypeScript Compiler was given no files for compilation, so it will skip compiling
but could not find the 'build action' for any typescript files. I looked in properties but none there. Path to locate it ??
Thanks in advance
Rao

Integrrate Parse cloud with phonegap

I am using phonegap to build parse cloud..First i tried to build code with my browser and checked in that it works without any errror. But when i copied to eclipse (phonegap) ,
Parse.Initialize line is getting error:
Error:
Uncaught ReferenceError: Parse is not defined at file:///android_asset/www/index.html:36
MYCODE:
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/parse-1.2.18.min.js"></script>
<script type="text/javascript">
$(document).on('pageshow', '#index', function(){
Parse.initialize("HxxxxxxxxxxxxxmALn","x5qxxxxxxxxxxxxxxxxxxxxxVk"); });
</script>

Android PhoneGap HTML5video

I am looking for an HTML 5 video plugin for PhoneGap.
I found a plugin at GitHub but there maybe something wrong as I have the following issues:
I don't know where to place the plugin.xml
I don't know how to to link with it <video> tag
and it's not working with PhoneGap
this javascript function now
function start(){
window.plugins.html5video.initialize({"video1" : "movie.mp4"});
window.plugins.html5video.play("video1");
}
04-24 09:52:59.305: E/Web Console(740): Uncaught TypeError: Cannot call method 'initialize' of undefined at file:///android_asset/www/index.html:44
After several attempts I solved this way:
I have installed Git
I have installed the plugin HTML5Video for Cordoba with command cordova plugin add https://github.com/jaeger25/Html5Video.git (with this command, the project has run automatically configured to use the plugin)
I created the folder platforms\androis\res\raw\ where I copied the video splash.mp4
In the html file (in my case \www\splash.html) I insert this code in HEAD:
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" src="Html5Video.js"></script>
<script>
// Wait for device API libraries to load
//
function onLoad() {
document.addEventListener("deviceready", onDeviceReady, false);
}
// device APIs are available
//
function onDeviceReady() {
window.plugins.html5Video.initialize({
"splashvideo" : "splash.mp4"
})
window.plugins.html5Video.play("splashvideo");
}
</script>
and this is the BODY code
<body onload="onLoad()">
<video id="splashvideo" autobuffer controls="false"></video>
</body>
It's work for me ;)

Categories

Resources