简体   繁体   中英

Cordova adding plugins in android project is very slow

We are automating the build of APKs on CI, but the whole process is taking around 10 minutes and 80% of time is consumed by this phase.

Discovered plugin "cordova-plugin-statusbar" in config.xml. Adding it to the project
Installing "cordova-plugin-statusbar" for android
Adding cordova-plugin-statusbar to package.json
Saved plugin info for "cordova-plugin-statusbar" to config.xml.

These are the plugins from config.xml

<plugin name="cordova-plugin-whitelist" spec="1.3.3" />
<plugin name="cordova-plugin-statusbar" spec="2.4.2" />
<plugin name="cordova-plugin-device" spec="2.0.2" />
<plugin name="cordova-plugin-splashscreen" spec="5.0.2" />
<plugin name="cordova-plugin-ionic-webview" spec="^2.0.0" />
<plugin name="phonegap-plugin-barcodescanner" spec="^8.0.0">
    <variable name="ANDROID_SUPPORT_V4_VERSION" value="27.+" />
</plugin>
<plugin name="cordova-plugin-camera-preview" spec="^0.10.0" />
<plugin name="cordova-plugin-screen-orientation" spec="^3.0.1" />
<plugin name="cordova.plugins.diagnostic" spec="^4.0.10" />
<plugin name="cordova-android-support-gradle-release" spec="^1.4.4">
    <variable name="ANDROID_SUPPORT_VERSION" value="26.+" />
</plugin>
<plugin name="cordova-sqlite-storage" spec="^2.4.0" />
<plugin name="cordova-plugin-ionic-keyboard" spec="^2.1.2" />
<plugin name="cordova-plugin-camera" spec="^4.0.3" />

Is it possible to speed up these process by somehow caching the results or any other way to speed up the installation of plugins?

If you place your Cordova plugins/ directory under version control (presumably in your Git repo), then when the project is checked out in the CI environment, Cordova will look for and use those local plugins instead of going away to fetch each one remotely via npm. This should make the process much quicker. If/when you need to update your plugins, just commit the updates to the repo.

While you could theoretically also commit platforms/ to your repo to make the build even faster (then Cordova won't have to install and build each platform project), I'd advise against this as the platform projects in a Cordova project should be considered volatile.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM