Cordova Development Common Issues

· 4 min read

When developing with ionic or directly using Cordova, you often encounter some problems. Here’s a summary, this article is continuously updated

Codename, Mark and Build Number Relationship

CodenameVersionAPI Level
Nougat7.1API Level 25
Nougat7.0API Level 24
Marshmallow6.0API Level 23
Lollipop5.1API Level 22
Lollipop5.0API Level 21
KitKat4.4-4.4.4API Level 19
Jelly Bean4.3.xAPI Level 18
Jelly Bean4.2.xAPI Level 17
Jelly Bean4.1.xAPI Level 16
Ice Cream Sandwich4.0.3-4.0.4API Level 15, NDK 8

For the latest and most complete information, click to view official documentation

Is crosswalk-webview needed?

cordova-plugin-crosswalk-webview

This plugin mainly solves performance issues on older phones with laggy APP operations. However, if you don’t need to support very old phones (Android 4.4 and below), it’s not recommended to install.

Before Android 4.4, the Android system browser kernel was WebKit. Android 4.4 switched the system browser to Chromium (kernel is Blink, a fork of Webkit).

Installing this plugin means using Crosswalk Webview to replace the system’s WebView. Essentially, it brings Chromium into the APP, but Android 4.4 and later have already switched to Chromium.

Advantages:

  • Not dependent on Android version
  • Compatibility
  • Performance improvement compared to old system webviews

Disadvantages:

  • Increases memory usage
  • Increases APK size (about 17MB)
  • Increases installation size (about 50MB)

config.xml file modification, need to re-add platform?

  • For ionic projects, not needed. Execute ionic cordova build platform or ionic cordova run platform, ionic-cli directly updates the corresponding code in the platform.
  • For Cordova initialized projects, you need to rm and then add.

iOS - Photo Library Permissions

If the APP doesn’t declare camera permissions, during actual APP operation, accessing the photo library will cause the APP to crash directly with an error. So you must add the corresponding plugin, specific configuration information is as follows:

 <edit-config target="NSCameraUsageDescription" file="*-Info.plist" mode="merge">
      <string>need camera access to take pictures</string>
    </edit-config>
    <edit-config target="NSMicrophoneUsageDescription" file="*-Info.plist" mode="merge">
      <string>need microphone access to record sounds</string>
    </edit-config>
    <edit-config target="NSPhotoLibraryUsageDescription" file="*-Info.plist" mode="merge">
      <string>need to photo library access to get pictures from there</string>
    </edit-config>
    
<plugin name="cordova-plugin-media-capture" spec="~1.4.3">
    <variable name="CAMERA_USAGE_DESCRIPTION" value="App would like to access the camera."/>
    <variable name="MICROPHONE_USAGE_DESCRIPTION" value="App would like to access the microphone."/>
    <variable name="PHOTOLIBRARY_USAGE_DESCRIPTION" value="App would like to access the library."/>
  </plugin>

Note that the content in the edit-config tags will be packaged into the info.plist file. This section must be written, otherwise the final packaged APP submission will fail.

iOS - Build upload successful but not showing in versions

If the build upload shows success, but you don’t see it in iTunes Connect -> Activity -> All Build Versions, it means the submitted APP was rejected. There will be an email explaining the error information. For example, the following information:

Missing Info.plist key - This app attempts to access privacy-sensitive data without a usage description. The app’s Info.plist must contain an NSPhotoLibraryUsageDescription key with a string value explaining to the user how the app uses this data. Once these issues have been corrected, you can then redeliver the corrected binary.

After fixing accordingly, submit again, and simply refresh the page to see the submitted version and its status.

Could not find an installed version of Gradle

The complete error is:

Could not find an installed version of Gradle either in Android Studio, or on your system to install the gradle wrapper. Please include gradle in your path, or install Android Studio

The official website has relevant introduction as follows:

As of cordova-android@4.0.0, Cordova for Android projects are built using Gradle.

So the problem is understood. The solution is exactly as the error suggests - install Gradle.

If using mac, it’s recommended to execute brew install gradle.

com.android.ide.common.process.ProcessException: Failed to execute aapt

Executing cordova build android will report this error, caused by crosswalk-webview in the project. Solutions:

  1. Uninstall cordova-plugin-crosswalk-webview plugin cordova plugin rm cordova-plugin-crosswalk-webview
  2. Install cordova-android-support-gradle-release plugin cordova plugin add cordova-android-support-gradle-release Both methods work, depending on whether we still want to use crosswalk. For its advantages and disadvantages, click here