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.
Use
cordova plugin add cordova-plugin-console
This plugin will enable console logging.
It has various methods for console printing
By default plugin is not installed so you will have to add it manually.
Regards.
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
)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.