Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Chrome 'onLaunched' error in plugin

I am following the google chrome web app development on http://developer.chrome.com/trunk/apps/first_app.html and the web app is not launching. when i click on the app icon on the page it closes the tab. I have downloaded the sample apps and plugins from github but they too are not working when i look at the console i get this error, please not i have enabled experimental API's in chrome://flags.

Uncaught TypeError: Cannot read property 'onLaunched' of undefined 

I have updated my chrome browser to version 22.0.1229.79. My manifest.json file is

{
"name": "Hello World!",
"description": "My first packaged app.",
"manifest_version": 2,

"version": "0.1",
"app": {
    "background": {
        "scripts": ["background.js"]
    }
},
"icons": {
    "16": "calculator-16.png", 
    "128": "calculator-128.png"
}

}

And my background.js file

   chrome.app.runtime.onLaunched.addListener(function() {
    chrome.app.window.create('window.html', {
        'width': 400,
        'height': 500
    });
});

Can someone point me where am going wrong?

like image 884
Madawar Avatar asked Sep 28 '12 17:09

Madawar


People also ask

How to allow Chrome to open applications?

Go to Allow/block mode. Click Edit. For Play Store, choose what type of apps and extensions you want to let users install.

What is app runtime for Chrome beta?

Android Runtime for Chrome (ARC) is a compatibility layer and sandboxing technology for running Android applications on desktop and laptop computers in an isolated environment. It allows applications to be safely run from a web browser, independent of user operating system, at near-native speeds.

How to block games on Chrome?

Navigate to Devices > Chrome > Apps and Extensions. Select the "Block all other apps and extensions" option from the dropdown for the Allow or Block Apps and Extension field.


1 Answers

This error also occurs if you leave out the "app": {} declaration in the manifest.json.

I.e. "background": { "scripts": [ "background.js" ] }, Will give this error.

And "app": { "background": { scripts": ["background.js"] }, will work properly.

like image 196
Splaktar Avatar answered Nov 09 '22 17:11

Splaktar