Cuttlefish
Cuttlefish (CVD) is a virtual Android device framework that allows you to run Android virtual devices on various hosts. It is widely used in the context of AOSP (Android Open Source Project) development, including in automotive contexts. The Cuttlefish setup includes a set of commands prefixed with cvd that manage these virtual devices.
Common Cuttlefish Commands
Here are some of the most common Cuttlefish commands:
cvd start: This command is used to start a Cuttlefish virtual device instance. By default, it starts one instance of the Android virtual device.Usage:
cvd startYou can pass additional flags to customize the start process, such as specifying the instance number or other configurations.
cvd stop: Stops a running Cuttlefish virtual device instance.Usage:
cvd stopYou can stop specific instances by providing the instance number, e.g.,
cvd stop --instance 2.
cvd status: Displays the status of all running Cuttlefish instances.Usage:
cvd statusYou can see whether the instance is running or stopped, along with additional details about each instance.
cvd reset: This command resets the Cuttlefish instance, effectively reinitializing the device.Usage:
cvd resetYou can also reset specific instances with
--instanceflag.
cvd kill: Kills the entire Cuttlefish process for a given instance.Usage:
cvd kill
cvd stop-group: Stops all instances in a group.Usage:
cvd stop-group
cvd logs: Fetches and displays logs for debugging purposes.Usage:
cvd logs --instance <id>
cvd restart: Restarts the Cuttlefish instance.Usage:
cvd restart
cvd help: Displays help information for thecvdcommand suite.Usage:
cvd help
Concepts of CVD Instance and CVD Groups
CVD Instance: A CVD instance represents a single virtual Android device running on your host. Each instance has its own dedicated resources and configuration. You can run multiple CVD instances simultaneously, each identified by an instance ID.
When you start a Cuttlefish virtual device using the
cvd startcommand, it creates a new instance. If you specify multiple instances, Cuttlefish will manage each separately.Example: Running multiple instances can be done with
cvd start --num_instances 2, which starts two instances.
CVD Group: A CVD group is a collection of CVD instances that are treated as a single entity for certain operations. This is useful when managing multiple instances collectively, such as stopping or starting them all at once.
For example, using
cvd stop-groupwould stop all instances in the group instead of managing them individually.
Managing Multiple CVD Instances
You can manage multiple CVD instances through a combination of instance-specific commands and flags. Here’s how you can handle multiple instances:
Starting multiple instances: You can start multiple CVD instances by using the
--num_instancesflag with thecvd startcommand.Example:
cvd start --num_instances 3would start three virtual Android devices.
Controlling specific instances: Most CVD commands accept an
--instanceflag to target specific instances by their ID.Example:
cvd stop --instance 2would stop instance 2.
Viewing instance details: You can view the details of all running instances with the
cvd statuscommand. This will show you the instance IDs and their statuses.Example:
cvd status
Stopping all instances: You can stop all running instances at once using
cvd stop-group. This is useful when you have multiple instances running and want to shut them down in a single command.Example:
cvd stop-group
Resetting specific instances: To reset a particular instance, you can use the
cvd resetcommand with the instance ID.Example:
cvd reset --instance 3
Fetching logs for specific instances: Use
cvd logs --instance <id>to retrieve logs for individual instances. This is helpful for debugging issues with specific virtual devices.
Example Workflow with Multiple Instances
Start three instances of CVD:
Check the status of all instances:
Stop the second instance:
Reset the first instance:
Stop all instances at once:
By using these commands and concepts, you can efficiently manage multiple virtual Android devices in your Cuttlefish setup, making it easier to work with AOSP environments, including for automotive development or general Android testing purposes.
Last updated