Installation
  • 07 Jun 2024
  • 1 Minute to read
  • Contributors
  • Dark
    Light

Installation

  • Dark
    Light

Article summary

It is recommended that users obtain the Speech SDK via Maven. Simply make this addition to your project build.gradle to define the Vuzix repository.

allprojects { 
	repositories { 
		google() jcenter() 
		// The speech SDK is currently hosted by jitpack 
		maven { url "https://jitpack.io" } 
	} 
}

Then add a dependency to the Speech SDK library in your application build.gradle

dependencies {
	implementation 'com.vuzix:sdk-speechrecognitionservice:1.7'
}


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 jitpackmaven 
		{ 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 Speech 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.

# Vuzix speech recognition requires the SDK names not be obfuscated-keep 
class com.vuzix.sdk.speechrecognitionservice.** { *; }

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


Was this article helpful?