Maven migration guide
With the release v1.6.8 we are moving away from distributing static .aar
files on our GitHub Repository
and starting to distribute our libraries via Maven. This means there will also be changes in the way you integrate our libraries.
This is a short guide on how we suggest you migrate from using static .aar
files and start using our libraries via Maven.
How .aar
libraries were added until now¶
There are two ways you could include an .aar
library into an Android project until now:
-
As a separate module¶
This was possible through Android Studio until a few versions ago - you could go to
File -> New -> New Module -> Import .JAR-.AAR Package
, and select the.aar
file you wanted to include in your project. This would create a new module in your project, which would contain only a smallbuild.gradle
file and your.aar
file. It would also add an entry to yoursettings.gradle
file for the new module.Here is an example of what this looks like for our
LibBlinkReceiptCore.aar
library in our GitHub sample app - link.After that, you could reference the new module in your other modules, e.g. your app module, by adding it as a dependency in your
build.gradle
dependency block:build.gradledependencies { implementation project(":LibBlinkReceiptCore") }
-
Copying the files into your project¶
The second way was copying the
.aar
file(s) into your project, usually into alibs
folder in the root of your project, and then referencing it in yourbuild.gradle
files like this:build.gradledependencies { implementation files("../libs/LibBlinkReceiptCore.aar") }
But this would only add our binary .aar
file to your project, which meant you also had to include all our transitive dependencies manually - and
keep track of them as we updated them.
How to migrate to our Maven integration¶
We’ve migrated over to using Maven as our main and recommended way of distributing our libraries and keeping track of our transitive dependencies. So, here are the steps you need to take to migrate over to using our maven integration:
-
Remove the old integration¶
-
Integration as a separate module¶
If your current integration was As a separate module, you’ll have to remove/delete those modules for all of our libraries. I.e., if you were using our
LibBlinkReceiptRecognizer
module to scan physical receipts, you also had to useLibBlinkReceiptCore
,LibBlinkReceiptCamera
, and possiblyLibBlinkReceiptCameraUi
, which means you would have to delete each of these modules. Then, remove theinclude
entries from thesettings.gradle
for those modules, i.e.:settings.gradleLastly, remove the dependency declarations for these modules, i.e.:include ':app' -include ':LibBlinkReceiptCore' -include ':LibBlinkReceiptRecognizer' -include ':LibBlinkReceiptCamera' -include ':LibBlinkReceiptCameraUi'
build.gradledependencies { ...//your other dependencies -implementation(project(':LibBlinkReceiptCore')) -implementation(project(':LibBlinkReceiptRecognizer')) -implementation(project(':LibBlinkReceiptCamera')) -implementation(project(':LibBlinkReceiptCameraUi')) }
-
Integration by copying the files to your project¶
If your current integration was by Copying the files into your project, you’ll have to delete the
.aar
files from your project. I.e., if you were using ourLibBlinkReceiptRecognizer
module to scan physical receipts, you also had to useLibBlinkReceiptCore
,LibBlinkReceiptCamera
, and possiblyLibBlinkReceiptCameraUi
, you would have to deleteLibBlinkReceiptRecognizer.aar
,LibBlinkReceiptCore.aar
,LibBlinkReceiptCamera.aar
andLibBlinkReceiptCameraUi.aar
. Then, remove the dependency declarations to these files from your code, i.e.:build.gradledependencies { ...//your other dependencies -implementation(files("../libs/LibBlinkReceiptCore.aar")) -implementation(files("../libs/LibBlinkReceiptRecognizer.aar")) -implementation(files("../libs/LibBlinkReceiptCamera.aar")) -implementation(files("../libs/LibBlinkReceiptCameraUi.aar")) }
-
-
Add our Maven repository to your project configuration¶
Our libraries are hosted on our own Maven server, at https://maven.microblink.com. To be able to reference our libraries, you have to add our Maven server to your project configuration. There are currently two ways of doing this, either in your root
build.gradle
file or in yoursettings.gradle
file. Older projects usually have the maven repositories declared in the rootbuild.gradle
, while newer ones have it insettings.gradle
. To add our Maven server to your project configuration, do the following, depending on if you have the config in yourbuild.gradle
orsettings.gradle
file:-
build.gradle¶
build.gradle.ktsallProjects { repositories { ... // your other repositories + maven { url "https://maven.microblink.com" } } }
build.gradleallProjects { repositories { ... // your other repositories + maven { url = uri("https://maven.microblink.com") } } }
-
settings.gradle¶
settings.gradle.ktsdependencyResolutionManagement { repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) repositories { ... // your other repositories + maven { url = uri("https://maven.microblink.com") } } }
settings.gradledependencyResolutionManagement { repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) repositories { ... // your other repositories + maven { url "https://maven.microblink.com" } } }
-
-
Remove transitive dependencies and reference our dependencies in your code¶
All that’s left is to remove transitive dependencies and add our maven dependency declarations in your
build.gradle
dependencies blocks. Since we’re using a BOM implementation for our maven integration, you only have to declare the root version of our SDK using the platform declaration. You can then declare only the necessary modules you want to use, without specifying a version. Here are the changes you are supposed to make in your build.gradle, for each of our library modules:build.gradledependencies { - implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.9.23") - implementation("androidx.appcompat:appcompat:1.7.0") - implementation("androidx.constraintlayout:constraintlayout:2.1.4") - implementation("com.squareup.okhttp3:okhttp:4.12.0") - implementation("com.squareup.retrofit2:retrofit:2.11.0") - implementation("com.squareup.retrofit2:converter-gson:2.11.0") - implementation("com.squareup.retrofit2:converter-scalars:2.11.0") - implementation("com.squareup.okio:okio:3.9.0") - implementation("com.google.android.gms:play-services-tasks:18.2.0") - implementation("com.google.android.gms:play-services-auth:21.2.0") - implementation("androidx.webkit:webkit:1.11.0") - implementation("androidx.work:work-runtime:2.9.1") - implementation("androidx.work:work-runtime-ktx:2.9.1") - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.1") - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.8.1") - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-play-services:1.8.1") - implementation("androidx.core:core-ktx:1.13.1") + implementation(platform("com.microblink.blinkreceipt:blinkreceipt-bom:1.8.7")) + implementation("com.microblink.blinkreceipt:blinkreceipt-recognizer") //BlinkReceiptRecognizer doesn't depend on BlinkReceiptCameraUi, so if you want to use our default scanning UI you also have to include the following dependency + implementation("com.microblink.blinkreceipt:blinkreceipt-camera-ui") }
build.gradledependencies { - implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.9.23") - implementation("androidx.core:core-ktx:1.13.1") - implementation("androidx.work:work-runtime:2.9.1") - implementation("androidx.work:work-runtime-ktx:2.9.1") - implementation("androidx.appcompat:appcompat:1.2.0") - implementation("com.squareup.okhttp3:okhttp:4.12.0") - implementation("com.squareup.okhttp3:logging-interceptor:4.9.3") - implementation("com.squareup.retrofit2:retrofit:2.11.0") - implementation("com.squareup.retrofit2:converter-gson:2.11.0") - implementation("com.squareup.retrofit2:converter-scalars:2.11.0") - implementation("com.squareup.okio:okio:3.9.0") - implementation("com.google.android.gms:play-services-tasks:18.2.0") - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.1") - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.8.1") - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-play-services:1.7.2") - implementation("androidx.webkit:webkit:1.11.0") - implementation("androidx.datastore:datastore-preferences:1.1.1") + implementation(platform("com.microblink.blinkreceipt:blinkreceipt-bom:1.8.7") + implementation("com.microblink.blinkreceipt:blinkreceipt-account-linking") }
build.gradledependencies { - implementation("androidx.work:work-runtime:2.9.1") - implementation("androidx.work:work-runtime-ktx:2.9.1") - implementation( "com.microsoft.identity.client:msal:5.5.0" ) { - exclude group: "com.microsoft.device.display" -} - implementation("com.sun.mail:android-mail:1.6.7") - implementation("com.sun.mail:android-activation:1.6.7") - implementation("androidx.appcompat:appcompat:1.7.0") - implementation("androidx.constraintlayout:constraintlayout:2.1.4") - implementation("androidx.fragment:fragment-ktx:1.8.3") - implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.8.3") - implementation("androidx.lifecycle:lifecycle-livedata-ktx:2.8.3") - implementation("androidx.lifecycle:lifecycle-common-java8:2.8.3") - implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.8.5") - implementation("androidx.lifecycle:lifecycle-viewmodel-savedstate:2.8.3") - implementation("androidx.webkit:webkit:1.11.0") - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.1") - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.8.1") - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-play-services:1.8.1") - implementation("com.google.android.material:material:1.12.0") - implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.9.23") - implementation("androidx.core:core-ktx:1.13.1") - implementation("com.squareup.okhttp3:okhttp:4.12.0") - implementation("com.squareup.okhttp3:logging-interceptor:4.12.0") - implementation("com.squareup.retrofit2:retrofit:2.11.0") - implementation("com.squareup.retrofit2:converter-gson:2.11.0") - implementation("com.squareup.retrofit2:converter-scalars:2.11.0") - implementation("androidx.constraintlayout:constraintlayout:2.1.4") - implementation("androidx.core:core:1.3.1") - implementation("com.squareup.okio:okio:3.9.0") - implementation("com.google.android.gms:play-services-tasks:18.2.0") - implementation("com.google.apis:google-api-services-gmail:v1-rev110-1.25.0" exclude module: "httpclient") - implementation("com.google.api-client:google-api-client-android:2.7.0" exclude module: "httpclient") - implementation("com.google.http-client:google-http-client-gson:1.45.0" exclude module: "httpclient") + implementation(platform("com.microblink.blinkreceipt:blinkreceipt-bom:1.8.7")) + implementation("com.microblink.blinkreceipt:blinkreceipt-digital") }
build.gradledependencies { - implementation("androidx.appcompat:appcompat:1.7.0") - implementation("com.google.android.gms:play-services-tasks:18.2.0") - implementation("com.squareup.okhttp3:okhttp:4.12.0") - implementation("com.squareup.okhttp3:logging-interceptor:4.12.0") - implementation("com.squareup.retrofit2:retrofit:2.11.0") - implementation("com.squareup.retrofit2:converter-gson:2.11.0") - implementation("com.squareup.retrofit2:converter-scalars:2.11.0") - implementation("com.squareup.okio:okio:3.9.0") + implementation(platform("com.microblink.blinkreceipt:blinkreceipt-bom:1.8.7")) + implementation("com.microblink.blinkreceipt:blinkreceipt-earnings") }
build.gradledependencies { - implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.9.23") - implementation("androidx.appcompat:appcompat:1.7.0") - implementation("androidx.core:core-ktx:1.13.1") - implementation("androidx.work:work-runtime:2.9.1") - implementation("androidx.work:work-runtime-ktx:2.9.1") - implementation("com.squareup.okhttp3:okhttp:4.10.0") - implementation("com.squareup.okhttp3:logging-interceptor:4.10.0") - implementation("com.squareup.retrofit2:retrofit:2.11.0") - implementation("com.squareup.retrofit2:converter-gson:2.11.0") - implementation("com.squareup.retrofit2:converter-scalars:2.11.0") - implementation("com.squareup.okio:okio:3.9.0") - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.8.1") - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.1") - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-play-services:1.8.1") - implementation("com.google.android.gms:play-services-tasks:18.2.0") - implementation("com.google.android.material:material:1.12.0") - implementation("androidx.constraintlayout:constraintlayout:2.1.4") - implementation("androidx.fragment:fragment-ktx:1.8.3") - implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.8.3") - implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.8.5") + implementation(platform("com.microblink.blinkreceipt:blinkreceipt-bom:1.8.7")) + implementation("com.microblink.blinkreceipt:blinkreceipt-surveys") }
build.gradledependencies { - implementation("androidx.appcompat:appcompat:1.7.0") - implementation("com.squareup.okhttp3:okhttp:4.12.0") - implementation("com.squareup.retrofit2:retrofit:2.11.0") - implementation("com.squareup.retrofit2:converter-gson:2.11.0") - implementation("com.squareup.retrofit2:converter-scalars:2.11.0") - implementation("com.squareup.okhttp3:logging-interceptor:2.9.0") - implementation("com.squareup.okhttp3:logging-interceptor:2.9.0") - implementation("com.squareup.okio:okio:3.9.0") - implementation("androidx.lifecycle:lifecycle-runtime:2.6.1") - implementation("com.google.zxing:core:3.5.1") - implementation("com.google.android.gms:play-services-tasks:18.2.0") + implementation(platform("com.microblink.blinkreceipt:blinkreceipt-bom:1.8.7")) + implementation("com.microblink.blinkreceipt:blinkreceipt-barcode") }
build.gradledependencies { - implementation("androidx.appcompat:appcompat:1.7.0") - implementation("androidx.core:core-ktx:1.13.1") - implementation("androidx.work:work-runtime:2.9.1") - implementation("androidx.work:work-runtime-ktx:2.9.1") - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.1") - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.8.1") - implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.9.23") - implementation("com.squareup.okhttp3:okhttp:4.12.0") - implementation("com.squareup.okhttp3:logging-interceptor:4.12.0") - implementation("com.squareup.retrofit2:retrofit:2.11.0") - implementation("com.squareup.retrofit2:converter-gson:2.11.0") - implementation("com.squareup.retrofit2:converter-scalars:2.11.0") - implementation("com.google.android.gms:play-services-tasks:18.2.0") - implementation("com.squareup.okio:okio:3.9.0") - implementation("androidx.preference:preference-ktx:1.2.1") + implementation(platform("com.microblink.blinkreceipt:blinkreceipt-bom:1.8.7")) + implementation("com.microblink.blinkreceipt:blinkreceipt-core") }
build.gradledependencies { - implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.9.23") - implementation("androidx.core:core-ktx:1.13.1") - implementation("androidx.appcompat:appcompat:1.7.0") - implementation("com.google.android.material:material:1.11.0") - implementation("androidx.fragment:fragment:1.5.7") - implementation("androidx.fragment:fragment-ktx:1.8.3") - implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.1.0") + implementation(platform("com.microblink.blinkreceipt:blinkreceipt-bom:1.8.7")) + implementation("com.microblink.blinkreceipt:blinkreceipt-camera-ui") }
-
Combining multiple libraries¶
If you want to combine multiple libraries, you only have to declare the BOM dependency once, and then list the other dependencies, e.g., if you wanted to use the BlinkReceiptRecognizer, BlinkReceiptAccountLinking and BlinkReceiptDigital libraries in the same project, your dependencies block would look something like this:
dependencies { implementation(platform("com.microblink.blinkreceipt:blinkreceipt-bom:1.8.7")) implementation("com.microblink.blinkreceipt:blinkreceipt-recognizer") implementation("com.microblink.blinkreceipt:blinkreceipt-account-linking") implementation("com.microblink.blinkreceipt:blinkreceipt-digital") }
Since
BlinkReceiptRecognizer
depends onBlinkReceiptCore
andBlinkReceiptCamera
, it will pull them in without you having to declare them as dependencies. Same goes forBlinkReceiptAccountLinking
andBlinkReceiptDigital
which depend onBlinkReceiptCore
.