Adding HUD APIs, Resource, and Project Cleanup
  • 05 Sep 2024
  • 2 Minutes to read
  • Contributors
  • Dark
    Light

Adding HUD APIs, Resource, and Project Cleanup

  • Dark
    Light

Article summary

Configure build.gradle

Android projects have multiple build.gradle files. These files provide the compiler with compile-time information about the project. This information includes how to compile, what dependency libraries are used, where to get them, and which Android versions the application will support in addition to other application information.

For this example, it is important to configure the build.gradle file for the main app module. Please be sure to modify the correct file as shown below. Open the build.grade (Module: app), not the build.gradle (Project: BladeSampleApp) file. The screen below shows an unmodified version of the build.gradle file generated by Android Studio. There is some additional information here that we will remove shortly.


Default build.gradle

For simplicity of this example application, remove the testInstrumentationRunner line from the defaultConfig section.

And replace all of the dependencies in the dependencies section with simply implementation 'com.vuzix:hud-actionmenu:1.3' and implementation 'com.vuzix:hud-resources:1.2'. This dependency allows the Blade application to use dynamic theme and other Blade specific features. Refer to Dynamic Theme section for more information.

Note: Anytime this file is modified, Android Studio will display a warning stating that the files have changed, and a project sync should be performed. We will do a project sync after making other changes as well.

Before we can sync the project, let’s change the layout of the main activity as described in the next section.


Modified build.gradle


Change Default Activity Layout

By default, Android Studio will generate activities using a Constraint layout. For simplicity, this example uses the Relative layout.

Open the activity_main.xml layout (\res\layout\activity_main.xml).

The Layout will open on the "Design" Tab.

We recommend that you change your Default Device via the Device Editor to be the Vuzix Blade. If you have not created a device profile for the Blade in Android Studio, we strongly recommend you do so now to aid in the development of UI elements.


Notice the ConstraintLayout class is used as the main Layout Element.


Change the Layout to now be a RelativeLayout.

For more information on the Android Layouts or the ConstraintLayout class see the Android documentation:


To further simplify the layout, you can modify the following:

  • Remove the "xmlns:app="http://schemas.android.com/apk/res-auto" from the Top RelativeLayout definition.

  • Remove the constraint attributes (app:layout_constraintTop_toTopOf=”parent”, for instance) from the TextView element.


Note: The constraint layout requires a dependency. We removed that dependency when we modified the generated gradle.build file above.


Constraint Layout

Relative Layout

Sync the project

Now that we have modified the build.gradle file and simplified our activity layout, we are ready to sync the project.

Open the build.gradle file again and click on the Sync now link.

Android Studio will refresh the project using the modified build.gradle file and build the project.

If the build.gradle file and layout file are correct, the Build should complete successfully as shown below.



Once the project has built successfully, the Blade-specific libraries can be inspected in the Project window.

Change the project view from the Android view to the Project view in the top left of the file explorer.

Expand the External Libraries section to explore the hud-actionmenu and hud-resources classes.


hud-resources expanded


We now have all the Vuzix HUD resource and libraries.

These libraries will provide a lot of resources that will help you as a developer to build more intuitive apps with performance dedicated to the Vuzix Blade.

To learn more about these libraries, you can download the independent JavaDocs or read our section on them.


Was this article helpful?