1. Setting up the environment
1.1 Installing the Plugin
To integrate the Metric SDK into your Flutter project, you first need to add it to your project's dependencies. Open your pubspec.yaml file and include the following:
pubspec.yaml
dependencies:
  metric_sdk:
    git:
      url: https://github.com/Metric-Africa/metric-sdk-flutter.git
      ref: "0.1.0" # or the latest version
1.2 Configuring the Project-Level Gradle File
Next, you'll need to make some configurations specific to Android. Start by adding the Metric SDK repository to your project-level build.gradle file. This allows Gradle to locate and download the necessary dependencies.
build.gradle
allprojects {
    repositories {
        google()
        mavenCentral()
        maven {
            url "http://3.252.206.134:8081/artifactory/metric-sdk-sdk"
            allowInsecureProtocol = true
            credentials {
                username = artifactoryUser
                password = artifactoryPassword
            }
        }
    }
}
info
The artifactoryUser and artifactoryPassword will be provided upon request.
1.3 Updating the App-Level Gradle File
Minimum SDK Version
Update the minSdkVersion to 24 in your app-level build.gradle file:
build.gradle
android {
    ...
    defaultConfig {
        ...
        minSdkVersion 24
        ...
    }
    ...
}
Upgrade Android Plugin and Kotlin Version
Ensure you’re using the correct versions for the Android Gradle Plugin (AGP) and Kotlin.
build.gradle
plugins {
   ...
   id "com.android.application" version "8.2.2" apply false
   id "org.jetbrains.kotlin.android" version "1.9.22" apply false
}
Set Java Version
Specify the Java version to 17
build.gradle
android {
    ...
    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_17
        targetCompatibility = JavaVersion.VERSION_17
    }
}