- Print
- DarkLight
Adding HUD APIs, Resource, and Project Cleanup
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: Blade2SampleApp.app), not the build.gradle (Project: Blade2SampleApp) 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.
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:2.9.0' and implementation 'com.vuzix:hud-resources:2.3.0'. This dependency allows the Blade 2 application to use dynamic theme and other Blade 2 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.
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 2. If you have not registered the Vuzix Blade 2 as a device 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:
https://developer.android.com/guide/topics/ui/declaring-layout
https://developer.android.com/reference/android/support/constraint/ConstraintLayout
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.
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 2-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.
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 2.
To learn more about these libraries, you can find the JavaDocs below.
JavaDocs
For the HUD Resource Package: HUD-Resources Java Docs
For the HUD ActionMenu Package: HUD-ActionMenu Java Docs