Google Chrome 'onLaunched' error in plugin

 ̄綄美尐妖づ 提交于 2019-11-30 05:44:42

问题


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?


回答1:


Get a dev/beta copy of Chrome that is at least version 23.

I also had to add the following line to the manifest.json file before I could get the sample to run

{
  ...,
  "minimum_chrome_version": "23",
  ...
}



回答2:


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.




回答3:


The new-style packaged apps (with the background key in the app section in the manifest) are only supported in Chrome 23 (currently in the dev channel, soon to be in the beta channel) and later.




回答4:


You can follow the Chromium Development Calender here.



来源:https://stackoverflow.com/questions/12645069/google-chrome-onlaunched-error-in-plugin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!