Extension installed from Chrome Webstore throws error "Package is invalid. Details: 'Cannot load extension with file or directory name _metadata…'

旧时模样 提交于 2019-12-03 07:58:35

问题


When a CRX is added to the Chrome web store, Google adds a directory _metadata to the crx. Older versions of Chrome do not know about this directory (tested on Chrome 27) and throw this error:

Package is invalid. Details: 'Cannot load extension with file or directory name
_metadata. Filenames starting with "_" are reserved for use by the system.'.

You can see this error if you try to install this extension on an older version of Chrome: https://chrome.google.com/webstore/detail/allcast-receiver/hjbljnpdahefgnopeohlaeohgkiidnoe

A good explanation: https://groups.google.com/a/chromium.org/d/msg/chromium-apps/huDqSeaQx3Q/Z5GOMxA7lQIJ

Is there a workaround for this? This makes it impossible to support older versions of Chrome.


回答1:


You -as an extension developer- cannot work-around this bug, because the directory is added by the Chrome Web Store (CWS). You could work-around the bug by not using the CWS to distribute the extension, but then the extension cannot be used by the majority of Chrome users, because Google has actively tried to stop users from getting extensions from outside the CWS.

The CWS team are the only ones who can fix the bug. They should serve crx files without a _metadata directory if the user agent does not support the directory (Chrome 30-). This bug is being tracked on https://code.google.com/p/chromium/issues/detail?id=377278. So far, the response is:

We can't fix old versions of Chrome. Webstore side tracked at b/15176392, but extending support back to Chrome 30 is unlikely.

Star the issue to get notified of updates and to signal that you really want the bug to be fixed. If enough users/developers complain, then Google might fix the bug.




回答2:


You can try to unzip the CRX (change the suffix name to ".zip" if needed) and then in chrome: Settings -> Extensions check "Developer mode", choose "load unpacked extension.." and select the extracted folder.

P.S. I had to rename the folders starting with "_" (underscore) and remove the line "default_locale":"en", from the manifest JSON in order for that to work




回答3:


This answer applies to CRX files that you:

  • Downloaded from Chrome Web Store
  • Are trying to load unpacked

_locales folder should not pose problems. As long as the manifest contains default_locale key, Chrome will load the unpacked extension as expected.

_metadata is the problematic folder. It contains cryptographic hashes of all extension files to protect against tampering with those files, and is automatically added by CWS. This does not make sense in the context of an unpacked extension, and has no other use, so this folder simply needs to be deleted.




回答4:


Some people found resetting works. Some found emptying the recycle bin works. None worked for me. I re-installed chrome also didn't work.

Instead this worked for me (same as what Xan said): I download the .crx file, unzip it, erase the folder

_metadata

Then install it manually. This worked for me.




回答5:


DELETE THE _METADATA FOLDER AND I ASSURE YOU INTERNET DOWNLOAD MANAGER WILL BE ADDED AS ONE OF YOUR EXTENSIONS.



来源:https://stackoverflow.com/questions/23918539/extension-installed-from-chrome-webstore-throws-error-package-is-invalid-detai

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