Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

console.info not defined #308

Open
b-3-n opened this issue Jun 18, 2015 · 3 comments
Open

console.info not defined #308

b-3-n opened this issue Jun 18, 2015 · 3 comments
Milestone

Comments

@b-3-n
Copy link

b-3-n commented Jun 18, 2015

console.info is undefined for me. I'm deploying a cordova app inside the phone-gap developer app. Is this normal? (I tried installing https://git-wip-us.apache.org/repos/asf?p=cordova-plugin-console.git) without success.

@timkim
Copy link
Contributor

timkim commented Jul 6, 2015

Hi @MrGreen7

console.info should return as an object (just tested on iOS). And we do have that plugin installed though it's not quite up to date as the dev version in the repo you linked.

What device/os/version are you working on?

@slorber
Copy link

slorber commented Jul 9, 2015

@timkim I get the same problem with latest Android app, running on Nexus4 4.4.3.

sebastien@sebastien-xps:cordova (dev *+$)$ phonegap -v
5.1.1-0.29.0
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="format-detection" content="telephone=no" />
    <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />

    <link rel="stylesheet" type="text/css" href="app.css" media="screen"/>
    <link rel="stylesheet" type="text/css" href="appPrint.css" media="print"/>

    <script type="text/javascript" src="cordova.js"></script>
    <script type="text/javascript" src="appPolyfills.js"></script>
    <script type="text/javascript" src="appLibs.js"></script>
    <script type="text/javascript" src="app.js"></script>


    <title>Stample mobile app</title>
</head>
<body>
    <script>
        console.log("BEFORE: debug is defined="+!!console.debug);

        var stampleApp = require("app");

        var username = "xxx";
        var password = "yyy";


        function getBootstrapDataPromise() {
            return stampleApp.exports.apiAuthenticator.authenticate(username,password).then(function() {
                return stampleApp.exports.userRepository.getBootstrapData();
            });
        }

        function onDeviceReady() {
            console.log("onDeviceReady: debug is defined="+!!console.debug);
            console.debug = console.log;
            console.debug("test");
            getBootstrapDataPromise().then(function(bootstrapData) {
                stampleApp.start(bootstrapData);
            }).done();
        }

        document.addEventListener('deviceready', onDeviceReady, false);
    </script>

    <div id="reactAppContainer"></div>

</body>
</html>

Here are the ADP Logcat output:

D/CordovaWebViewClient(10307): onPageStarted(file:///data/data/com.adobe.phonegap.app/files/files/phonegapdevapp/www/index.html)
D/JsMessageQueue(10307): Set native->JS mode to null
D/CordovaActivity(10307): onMessage(onPageStarted,file:///data/data/com.adobe.phonegap.app/files/files/phonegapdevapp/www/index.html)
D/CordovaLog(10307): file:///data/data/com.adobe.phonegap.app/files/files/phonegapdevapp/www/index.html: Line 6 : The key "target-densitydpi" is not supported.
I/chromium(10307): [INFO:CONSOLE(6)] "The key "target-densitydpi" is not supported.", source: file:///data/data/com.adobe.phonegap.app/files/files/phonegapdevapp/www/index.html (6)
D/JsMessageQueue(10307): Set native->JS mode to OnlineEventsBridgeMode
V/StatusBar(10307): Executing action: _ready
W/CordovaPlugin(10307): Attempted to send a second callback for ID: StatusBar1517421497
W/CordovaPlugin(10307): Result was: "Invalid action"
D/CordovaActivity(10307): onMessage(spinner,stop)
D/CordovaNetworkManager(10307): Connection Type: wifi
D/CordovaNetworkManager(10307): Connection Extra Info: "LivingRoom"
D/dalvikvm( 4885): GC_CONCURRENT freed 1362K, 16% free 12281K/14604K, paused 2ms+6ms, total 69ms
D/dalvikvm( 4885): WAIT_FOR_CONCURRENT_GC blocked 47ms
D/CordovaLog(10307): file:///data/data/com.adobe.phonegap.app/files/files/phonegapdevapp/www/index.html: Line 38 : BEFORE: debug is defined=true
I/chromium(10307): [INFO:CONSOLE(38)] "BEFORE: debug is defined=true", source: file:///data/data/com.adobe.phonegap.app/files/files/phonegapdevapp/www/index.html (38)
D/CordovaLog(10307): file:///data/data/com.adobe.phonegap.app/files/files/phonegapdevapp/www/appLibs.js: Line 45612 : Download the React DevTools for a better development experience: https://fb.me/react-devtools
I/chromium(10307): [INFO:CONSOLE(45612)] "Download the React DevTools for a better development experience: https://fb.me/react-devtools", source: file:///data/data/com.adobe.phonegap.app/files/files/phonegapdevapp/www/appLibs.js (45612)
D/CordovaWebViewClient(10307): onPageFinished(file:///data/data/com.adobe.phonegap.app/files/files/phonegapdevapp/www/index.html)
D/CordovaActivity(10307): onMessage(onPageFinished,file:///data/data/com.adobe.phonegap.app/files/files/phonegapdevapp/www/index.html)
D/CordovaLog(10307): file:///data/data/com.adobe.phonegap.app/files/files/phonegapdevapp/www/index.html: Line 275 : deviceready has not fired after 5 seconds.
I/chromium(10307): [INFO:CONSOLE(275)] "deviceready has not fired after 5 seconds.", source: file:///data/data/com.adobe.phonegap.app/files/files/phonegapdevapp/www/index.html (275)
D/CordovaLog(10307): file:///data/data/com.adobe.phonegap.app/files/files/phonegapdevapp/www/index.html: Line 0 : ArrayBuffer is deprecated in XMLHttpRequest.send(). Use ArrayBufferView instead.
I/chromium(10307): [INFO:CONSOLE(0)] "ArrayBuffer is deprecated in XMLHttpRequest.send(). Use ArrayBufferView instead.", source: file:///data/data/com.adobe.phonegap.app/files/files/phonegapdevapp/www/index.html (0)
D/CordovaLog(10307): file:///data/data/com.adobe.phonegap.app/files/files/phonegapdevapp/www/index.html: Line 275 : onDeviceReady: debug is defined=false
I/chromium(10307): [INFO:CONSOLE(275)] "onDeviceReady: debug is defined=false", source: file:///data/data/com.adobe.phonegap.app/files/files/phonegapdevapp/www/index.html (275)
D/CordovaLog(10307): file:///data/data/com.adobe.phonegap.app/files/files/phonegapdevapp/www/index.html: Line 275 : test
I/chromium(10307): [INFO:CONSOLE(275)] "test", source: file:///data/data/com.adobe.phonegap.app/files/files/phonegapdevapp/www/index.html (275)
D/CordovaLog(10307): 

As you can see, the console.debug method is defined before the onDeviceReady, and afterward it is undefined. This is the same for error / warn. Only console.log is available after onDeviceReady.

Notice that I also tried to install the cordova console plugin. I was a bit confused by the documentation as I did not know what is the difference between installing the plugin with cordova plugin add cordova-plugin-console or with <plugin name="cordova-plugin-console" spec="1.0.1" /> but anyway in both case it does not work (even combining the 2). Can you please tell me if I'm doing it fine?

@slorber
Copy link

slorber commented Jul 9, 2015

please note that building and installing an APK does not have this problem and my console.debug statements are executed without trouble

@mwbrooks mwbrooks modified the milestone: Backlog Sep 11, 2015
@mwbrooks mwbrooks removed the backlog label Sep 11, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

4 participants