/**
  * Deploys an apk file to a connected emulator or usb device.
  *
  * @param apkFile the file to deploy
  * @throws MojoExecutionException If there is a problem deploying the apk file.
  */
 protected void deployApk(final File apkFile) throws MojoExecutionException, MojoFailureException {
   if (undeployBeforeDeploy) {
     undeployApk(apkFile);
   }
   doWithDevices(
       new DeviceCallback() {
         public void doWithDevice(final IDevice device) throws MojoExecutionException {
           String deviceLogLinePrefix = DeviceHelper.getDeviceLogLinePrefix(device);
           try {
             String result = device.installPackage(apkFile.getAbsolutePath(), true);
             // according to the docs for installPackage, not null response is error
             if (result != null) {
               throw new MojoExecutionException(
                   deviceLogLinePrefix
                       + "Install of "
                       + apkFile.getAbsolutePath()
                       + " failed - ["
                       + result
                       + "]");
             }
             getLog()
                 .info(
                     deviceLogLinePrefix
                         + "Successfully installed "
                         + apkFile.getAbsolutePath()
                         + " to "
                         + DeviceHelper.getDescriptiveName(device));
           } catch (InstallException e) {
             throw new MojoExecutionException(
                 deviceLogLinePrefix + "Install of " + apkFile.getAbsolutePath() + " failed.", e);
           }
         }
       });
 }
 /**
  * @throws MojoExecutionException
  * @throws MojoFailureException
  */
 protected void deployDependencies() throws MojoExecutionException, MojoFailureException {
   Set<Artifact> directDependentArtifacts = project.getDependencyArtifacts();
   if (directDependentArtifacts != null) {
     for (Artifact artifact : directDependentArtifacts) {
       String type = artifact.getType();
       if (type.equals(APK)) {
         getLog()
             .debug(
                 "Detected apk dependency " + artifact + ". Will resolve and deploy to device...");
         final File targetApkFile = resolveArtifactToFile(artifact);
         if (undeployBeforeDeploy) {
           getLog().debug("Attempting undeploy of " + targetApkFile + " from device...");
           undeployApk(targetApkFile);
         }
         getLog().debug("Deploying " + targetApkFile + " to device...");
         deployApk(targetApkFile);
       }
     }
   }
 }