Import the samples into Android Studio. To do so, choose <strong>File</strong> >
<strong>Import
project (Eclipse, ADT, Gradle)</strong> and
select the {@code LunarGSamples/API-Samples/android} directory.
<p>You may see an error about missing components or missing SDK version.
Ignore this error message, and follow the installation prompts.</p>
<p>After several minutes, the <em>Project</em> pane should
resemble the window shown in Figure 1.</p>
<img src="../images/project-pane.png"
alt="Project pane after importing samples into Android Studio" id="figure1" />
<p class="img-caption">
<strong>Figure 1.</strong> Project pane displaying samples after they've been imported.
</li>
</ol>
<h2 id="compiling">Compiling Your Project</h2>
<p>To compile your project, follow these steps:</p>
<ol style="1">
<li>Select your project in the Android Studio <em>Project</em> panel.</li>
<li>From the <strong>Build</strong> menu, choose <strong>Make Module <module-name> </strong>.</li>
<li>Resolve any dependency issues, and then compile. As Figure 2 shows, you can select individual projects to compile by choosing them from the configuration pulldown.</li>
<img src="../images/config-pulldown.png"
alt="Selecting the "drawcube" project from the config pulldown id="figure2" />
<p class="img-caption">
<strong>Figure 2.</strong> Selecting an individual project to compile.
<p>To run your project, choose an APK to run by choosing <strong>Run</strong> > <strong>Run <project-name></strong>.</p>
<p>To debug an APK, choose <strong>Run</strong> >
<strong>Debug <project-name></strong>. For each project,
there’s a Java version and a native (C or C++) version. Run the
native version of the app. For example, for drawcube,
run drawcube-native.</p>
<p>Most of the samples have simple functionality, and most stop
automatically after running. The drawcube example is one of
the more visually interesting examples. When you run it, it
should display the image in Figure 3</p>.
<img src="../images/drawcube-output.png"
alt="Successfully running shows a multicolored cube" id="figure3" />
<p class="img-caption">
<strong>Figure 3.</strong> The successfully compiled program runs and produces a display.
</p>
<h2 id="using">Using the Dynamic Loader</h2>
<p>
The samples use a dynamic loader helper function defined in {@code vulkan_wrapper.h/cpp} to
retrieve Vulkan API pointers using {@code dlopen()} and {@code dlsym()}. It does this rather
than statically linking them with {@code vulkan.so}.
</p>
<p>
Using this loader allows the code to link against API level 23 and earlier versions of the platform, which don’t include the {@code vulkan.so} shared library, but can run on devices that support Vulkan API.
</p>
<p>
The following snippet shows how to use the dynamic loader.
</p>
<pre>
#include "vulkan_wrapper.h" // Include Vulkan_wrapper and dynamically load symbols.