PhoneGap旧项目编译报错:Build仓库插件将不可访问,求替换方案
Hey there! I’ve tackled this exact issue with legacy PhoneGap apps before—let’s break down how to fully migrate your plugins from the deprecated PhoneGap Build repository to npm, including the specific plugin you found:
Step 1: Audit Your Current Plugins
First, pull up your project’s config.xml and identify all plugins tied to the PhoneGap Build repository. These will usually have a source="pgb" attribute in their <plugin> tag, or use old-style IDs like org.apache.cordova.*. Jot down every such plugin so you don’t miss any during migration.
Step 2: Replace the Identified npm Plugin (cordova-plugin-st...)
For the plugin you already located on npm, follow these steps:
- Uninstall the old PhoneGap Build version:
cordova plugin remove cordova-plugin-st... # Use PhoneGap CLI instead if that’s your workflow: # phonegap plugin remove cordova-plugin-st... - Install the npm-hosted version:
cordova plugin add cordova-plugin-st... # Pin to a specific version for stability, e.g.: # cordova plugin add cordova-plugin-st...@1.2.3 - Update your config.xml:
Replace the old plugin entry (which might look like<plugin name="cordova-plugin-st..." source="pgb" />) with the npm-compatible syntax. Specifying a version prevents unexpected breaking changes later:<plugin name="cordova-plugin-st..." spec="^1.2.3" />
Step 3: Migrate All Remaining Plugins
Repeat the above process for every other PhoneGap Build plugin in your list:
- For each plugin, search npm for its Cordova-compatible equivalent (most legacy PhoneGap plugins have been migrated to npm with names starting with
cordova-plugin-). - Double-check the plugin’s documentation to confirm API compatibility—most maintainers keep core functionality consistent, but there might be minor tweaks (like renamed methods or new parameters) that need code adjustments.
- If a plugin has no direct npm replacement, look for a popular alternative that provides the same features.
Step 4: Clean, Build, and Test
Once all plugins are replaced:
- Clear your build cache to avoid leftover conflicts:
cordova clean # Or phonegap clean - Recompile your project for your target platform(s):
cordova build android # Or cordova build ios, depending on your needs - Run thorough tests on all plugin-dependent features—pay extra attention to edge cases to ensure nothing breaks during the shift.
Step 5: Long-Term Maintenance
- Moving forward, always install plugins directly from npm using
cordova plugin add [plugin-name]—avoid any plugins that reference the PhoneGap Build repository. - Periodically update your plugins with
cordova plugin updateto get security patches and new features.
内容的提问来源于stack exchange,提问作者Jorge Lizaso

