- Print
- DarkLight
It is recommended that developers obtain the Barcode SDK via Maven. Simply make this addition to your project build.gradle to define the Vuzix repository.
allprojects {
repositories {
google()
jcenter()
// The Vuzix barcode SDK is currently hosted by jitpack
maven { url "https://jitpack.io" }
}
}
Then add a dependency to the Barcode SDK library in your application build.gradle
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
// To maintain consistency, configure this project to use the latest such as:
// implementation 'com.vuzix:sdk-barcode:**VERSION**'
// Alternatively you may use the latest library which will automatically update
// from time to time. This is not recommended for production projects:
implementation 'com.vuzix:sdk-barcode:master-SNAPSHOT'
}
The latest version is:
Gradle 7 and above
If you are using a Gradle version at 7 or above you may see this error:
"A problem occurred evaluating root project 'My Application'. > Build was configured to prefer settings repositories over project repositories but repository 'maven' was added by build file 'build.gradle'"
This is because Gradle is now recommending that you define your repositories in settings.gradle instead of the project build.gradle.
You can either revert back to preferring the project files by adding this to settings.gradle and keeping the definitions above.
include ':app'
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.PREFER_PROJECT)
}
Or you can define the repositories in the settings.gradle file like this.
include ':app'
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
// This will make your build fail if the Project tries to define repositories.
repositories {
google()
mavenCentral()
jcenter() // Warning: this repository is going to shut down soon
// e.g this is how you would add jitpack
maven { url "https://jitpack.io" }
// Add any repositories you would be adding to all projects here
}
}
You will then need to remove the allprojects{} block in the project build.gradle file.
Proguard Rules
If you are using Proguard you will need to prevent obfuscating the Vuzix Barcode SDK. Failure to do so will result in calls to the SDK raising the RuntimeException "Stub!". Add the following -keep statement to the proguard rules file, typically named proguard-rules.pro.
-keep class com.vuzix.sdk.barcode.** { *; }
The R8 Optimization may omit arguments required by the SDK methods, resulting in the NullPointerException "throw with null exception" being raised. The current workaround is to disable R8 and use Proguard to do the shrinking and obfuscation. Add the following to your gradle.properties to change from R8 to Proguard.
android.enableR8=false