Build a Virtual Device

In order to build the Virtual Device of an Application, the SDK provides the Gradle buildVirtualDevice task. Refer to the Virtual Device page for more information about the Virtual Device.

The prerequisites to use the buildVirtualDevice task are:

  • The Application EntryPoint must be configured, as described in Configure a Project.
  • A target VEE that uses an Architecture version 7.17 minimum must be defined:
    • If your VEE is a VEE Port, refer to the Select a VEE Port page to know the different ways to provide a VEE Port for a module project.
    • If your VEE is a Kernel, refer to the Select a Kernel page to know the different ways to provide a Kernel for a module project.

Once these prerequisites are fulfilled, the Virtual Device can be built:

By double-clicking on the buildVirtualDevice task in the Gradle tasks view:

../_images/intellij-buildVirtualDevice-gradle-project.png

When the build is completed, the Virtual Device is available in the build/virtualDevice folder of the project.

Note

If the provided VEE is a Kernel, the generated Virtual Device is an augmented version of the Kernel Virtual Device, in which the Application is set as a Pre-Installed Application.

The Virtual Device can then be used to run an Application on the Simulator for example.

Add a Pre-Installed Application in a Virtual Device

When building a Virtual Device for a Kernel, Applications can be pre-installed inside. These Applications can be loaded and started when the Kernel starts for example.

To install an Application in a Virtual Device for a Kernel, you must declare the Application as a dependency of the project in the build file, with the microejApplication configuration:

dependencies {
   microejApplication("com.mycompany:myapp:1.0.0")
}

Warning

  • Only modules with the Application Module Nature can be declared this way (modules built with the com.microej.gradle.application plugin). Declaring a module with another Module Nature would make the build fail.
  • The VEE Port used to create the Virtual Device has to be a Multi-Sandbox VEE Port to support the load of these pre-installed Applications.

Add a Kernel API in a Virtual Device

When building a Virtual Device for a Kernel, the Kernel must define the set of classes, methods and static fields all applications are allowed to use. This can be done by declaring Kernel APIs as a dependency in the build file:

dependencies {
   implementation("com.microej.kernelapi:edc:1.2.0")
}

Skip Virtual Device Build by Default

The Virtual Device of an Application is part of the artifacts that are automatically built and published. If you don’t want to build and publish the Virtual Device, the produceVirtualDeviceDuringBuild(false) method can be added in the microej configuration block of the Gradle build file of the project:

microej {
  produceVirtualDeviceDuringBuild(false)
}