Ionic Capacitor

Requirements

Ionic Capacitor development environment setup

Supported Android Version:

API 24+ & CompileSDK version 34.

Supported iOS Version

iOS 13+

Plugin installation

Install the Incode Cordova plugin in your app using the following command:

npm install https://github.com/Incode-Technologies-Example-Repos/incode-cordova-plugin.git

To enable the camera to capture ID and face, use the following command:

npm install @capacitor/camera

To enable the use of GeoLocation if it is required, use the following command:

npm install @capacitor/geolocation

Synchronize Capacitor

npx cap sync

Ensure your Capacitor configuration file (capacitor.config.ts or capacitor.config.json) is configured to support Cordova plugins.

capacitor.config.ts

const config: CapacitorConfig = {
  appId: 'com.example.app',
  appName: 'App Name',
  webDir: 'www',
  bundledWebRuntime: false,
  cordova: {
    preferences: {}
  }
};

export default config;

capacitor.config.json

{
  "appId": "com.example.app",
  "appName": "App Name",
  "webDir": "www",
  "bundledWebRuntime": false,
  "cordova": {
    "preferences": {}
  }
}

Additional Setup for iOS

Podfile

source 'https://github.com/CocoaPods/Specs.git'
source 'git@github.com:Incode-Technologies-Example-Repos/IncdDistributionPodspecs.git'
npx cap sync

Troubleshooting

Android Error: Execution failed for task ':app:processDebugMainManifest'. [capacitor] > Manifest merger failed : Attribute application@allowBackup value=(true) from AndroidManifest.xml:5:9-35 [capacitor] is also present at [com.incode.sdk:welcome:5.19.0] AndroidManifest.xml:31:9-36 value=(false).

Solution:

Add the tools:replace="android:allowBackup" attribute to the <application>element in android/app/src/main/AndroidManifest.xml and declare the tools namespace in the <manifest> element.

XML

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="com.example.app">

<application
        android:name=".MainApplication"
        android:label="@string/app_name"
        android:icon="@mipmap/ic_launcher"
        android:allowBackup="false"
        tools:replace="android:allowBackup"
        android:theme="@style/AppTheme">
        ...
    </application>

</manifest>

Synchronize Capacitor

npx cap sync

Android Error: AndroidManifest.xml Error:

[capacitor] uses-sdk:minSdkVersion cannot be smaller than version declared in library [:capacitor-app]

Solution:

You can try forcing the minSdkVersion setting in the global android/build.gradle file to make sure all dependencies are using it.

Groovy

allprojects {
    repositories {
        google()
        jcenter()
    }

subprojects {
        afterEvaluate { project ->
            if (project.hasProperty("android")) {
                android {
                    compileSdkVersion = 34
                    defaultConfig {
                        minSdkVersion = 24
                        targetSdkVersion = 34
                    }
                }
            }
        }
    }
}

Add tools:overrideLibrary

If the problem persists, you can add tools:overrideLibrary in the android/app/src/main/AndroidManifest.xml file to force the use of the library.

XML

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="com.example.app">

<application
        android:name=".MainApplication"
        android:label="@string/app_name"
        android:icon="@mipmap/ic_launcher"
        android:allowBackup="false"
        tools:replace="android:allowBackup"
        tools:overrideLibrary="com.capacitorjs.plugins.app"
        android:theme="@style/AppTheme">
        ...
    </application>

</manifest>