Description of the problem:
I have a small Ionic app I'm trying to migrate from Cordova to Capacitor, and I'm finding that the APK generated with Capacitor (using Android Studio to generate a signed APK) is quite a bit larger than my app built with Cordova. As a test I built the Ionic blank starter app both ways and with Cordova the APK is about 2MB, but with Capacitor the APK is about 4MB. Inspecting the APKs I see these differences:
Cordova Capacitor
------- ---------
classes.dex 66.8KB 1.4MB
resources.arsc 3.7KB 461.8KB
Am I missing some optimization step in the Capacitor build?
Affected platform
OS of the development machine
Other information:
Ionic:
Ionic CLI : 5.2.7 (/usr/local/lib/node_modules/ionic)
Ionic Framework : @ionic/angular 4.8.1
@angular-devkit/build-angular : 0.801.3
@angular-devkit/schematics : 8.1.3
@angular/cli : 8.1.3
@ionic/angular-toolkit : 2.0.0
Capacitor:
Capacitor CLI : 1.1.1
@capacitor/core : 1.1.1
Cordova:
Cordova CLI : 9.0.0 ([email protected])
Cordova Platforms : android 8.0.0
Cordova Plugins : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 4.1.1, (and 4 other plugins)
Utility:
cordova-res : 0.6.0
native-run : 0.2.8
System:
Android SDK Tools : 26.1.1
NodeJS : v12.9.1 (/usr/local/bin/node)
npm : 6.10.2
OS : macOS Mojave
Xcode : Xcode 10.3 Build version 10G8
Capacitor version: 1.1.1
node version: 12.9.1
npm version: 6.10.2
CocoaPods version:
Steps to reproduce:
Build the Ionic blank starter app
Link to sample project:
Capacitor includes cordova-android for the plugin compatibility, also ships with a set of plugins. Some of them have dependencies to android support libraries and push plugin has FCM dependency, while you install plugins separately in Cordova apps.
OK, I see Capacitor has quite a big selection of built-in APIs. Unfortunately, I have no use for most of them. Can the unused ones be disabled, or are they considered an integral part of Capacitor? I try hard to minimize bundle sizes and including a bunch of stuff that my app doesn't need seems counterproductive.
Most helpful comment
OK, I see Capacitor has quite a big selection of built-in APIs. Unfortunately, I have no use for most of them. Can the unused ones be disabled, or are they considered an integral part of Capacitor? I try hard to minimize bundle sizes and including a bunch of stuff that my app doesn't need seems counterproductive.