Installation
  • 19 Dec 2023
  • 1 Minute to read
  • Contributors
  • Dark
    Light

Installation

  • Dark
    Light

Article summary

SDK Installation

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

allprojects { 
	repositories { 
		... 
		maven { url 'https://jitpack.io' } 
	}
}

Then add a dependency to the USB-C Viewer SDK library in your application build.gradle.

Java

dependencies { 
	implementation 'com.vuzix:sdk-usbcviewer:**VERSION**' 
	implementation "androidx.core:core-ktx:1.7.0" 
	implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.2" 
}

The latest version is:

For a full list of available SDK release tags, and syntax to add to non-gradle projects, please see our Jitpack Package Repository.


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.


Application Manifest

The AndroidManifest.xml file may require changes to interact with the USB-C Viewer.


Feature Declaration

Ensure the following line is in your AndroidManifest.xml to declare that you use the USB feature for your app:

<uses-feature android:name="android.hardware.usb.host" />

Automatically Launching Your Application

Optionally, you can add an intent-filter in your AndroidManifest.xml within an activity tag to automatically launch your app when the USB-C Viewer is connected to the phone.

<activity> 
	<intent-filter> 
		<action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" /> 	
	</intent-filter> 
	<meta-data android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" 
	android:resource="@xml/device_filter" /> 
</activity>


Was this article helpful?

What's Next