GithubHelp home page GithubHelp logo

rickfarmer / android-vm Goto Github PK

View Code? Open in Web Editor NEW
103.0 15.0 49.0 41 KB

Automated provisioning and configuration of an Ubuntu VM containing the Android development environment, including Android ADT Bundle with SDK, Eclipse & the Android NDK using the Vagrant DevOps tool with Chef and shell-scripts.

License: Apache License 2.0

Ruby 10.70% Shell 89.30%

android-vm's Introduction

android-vm

Automated provisioning and configuration of an Ubuntu VM containing the Android development environment, including Android ADT Bundle with SDK, Eclipse & the Android NDK using the Vagrant DevOps tool with Chef and shell-scripts.

This automated VM installation and configuration uses the excellent DevOps tool, Vagrant which works with both VirtualBox (free) and VMware Fusion & Workstation (paid plug-in) in addition to several Community Chef Cookbooks.

A special welcome to fellow Harvard classmates. This project was built with the Harvard CSCI E-65 Building Mobile Apps course in mind. However, there is no reason it cannot be used to provision a consistent, professional Android development environment.

Please feel free to contribute improvements and enhancements to the provisioning code & reporting issues or questions. The goal is to improve this Android VM project with community support.

Currently, it will provision an Android VM for development with the following specifications,

Clone the Android VM Code Repository

  1. Create a working directory to use for the Android VM project in, e.g. /csci65/android-vm or C:/csci65/android-vm

    In OS X & Linux, e.g.

     $ mkdir /csci65/android-vm
     $ cd /csci65/android-vm
    

    In Windows, e.g.

     $ mkdir c:\csci65\android-vm
     $ cd c:\csci65\android-vm
    
  2. Download or clone the project repository into the newly created directory on your local machine from one of the following sources,

    Visit the Android-VM repository on GitHub,

    https://github.com/rickfarmer/android-vm

    Clone the Android-VM repository directly from GitHub,

    https://github.com/rickfarmer/android-vm.git

    Download the Android-VM repository as a zip file,

    https://github.com/rickfarmer/android-vm/archive/master.zip

Install Vagrant

Note: Vagrant has a prerequisite of an installed and functioning version of one of the following virtualization products,

  1. Download and install the latest version of Vagrant for your OS from https://www.vagrantup.com/downloads.html

  2. If using VMware, install the purchased VMware Provider Plug-in as mentioned in the documentation

Install the Android VM

Note: All the software needed is automatically downloaded as it is needed. Several of the downloads are somewhat large. Patience is a virtue while the automated installation is running.

  1. From the newly created working directory, e.g.

     $ cd /csci65/android-vm 
     $ git submodule init
     $ git submodule update
    
  2. Run the following to start Vagrant and kick-off the process to build an Android VM,

    For VirtualBox,

     $ vagrant up
    

    For VMware Fusion,

     $ vagrant up --provider=vmware_fusion 
    

    For VMware Workstation

     $ vagrant up --provider=vmware_workstation 
    

    Note: As the Android VM build runs you will see various types of screen output from Vagrant, Chef and Shell scripts -- some of the dependency downloads and compilations require a bit of time. Again, Patience is a virtue.

  3. Once the Android VM build provisioning process is complete, run the following to login via SSH,

     $ vagrant ssh
    
  4. The Ubuntu Unity desktop UI is set to automatically launch on vagrant up, login using the credentials,

    • Username: vagrant
    • Password: vagrant
  5. The Android development environment directories with eclipse, sdk and ndk are located in the directory /usr/local/android/.

  6. The VM has an internal /vagrant directory which maps to the directory created previously (i.e. the one from which you are running the Android VM on your local machine), e.g. /csci65/android-vm or c:\csci65\android-vm maps to the internal VM directory /vagrant.

    The net effect is that anything you drop in your local working directory, e.g. e.g. /csci65/android-vm or c:\csci65\android-vm, can be accessed from within the VM by opening the directory "/vagrant" and vice-versa

Manually Configure the Android VM in the Virtualization Provider

To connect an Android device you must manually setup a USB connection mapping for your Android device to the new VM

This configuration will vary with your provider (hypervisor), VMware Fusion, Workstation, or VirtualBox.

For example, if using VMware Fusion perform the following steps,

  1. Plug your android device hardware into the computers USB port

  2. Open the 'Virtual Machine Library'

  3. Select the VM, e.g. "android-vm: default", right-click and choose 'Settings...'

  4. Select 'USB & Bluetooth', check the box next to your device and set the 'Plug In Action' to 'Connect to Linux'

  5. Plug the device into the USB port and verify that it appears when you run lsusb from the command line

  6. Your device should appear when running lsusb enabling you to use Android adb, e.g.

     $ adb devices
     	...
     	List of devices attached
     	007jbmi6          device
    
     $ adb shell
     	i.e. to log into the device (be sure to enable USB debugging on the device)
    

Note: Additionally you may want to change various settings in the Virtualization Provider to size memory and vCPUs allocated to the Android VM _Note: To open the terminal from desktop, use ctrl-alt-T for PC or control-option-T for Mac

Vagrant Basics & Workflow

Vagrant boxes are just pre-configured virtual machines that Vagrant uses as a template to clone.

To see the available boxes,

	$ vagrant box list
	...
	precise64   (vmware_fusion)
	precise64   (virtualbox)
	centos64    (vmware_fusion)

The box files (aka template VMs) are stored in ~/vagrant.d but you should not care since you manage the box files through vagrant.

When you issue vagrant up, vagrant will download the box from the url unless its already cached locally. Once available, it will clone the box into the directory you've chosen to work in, e.g. /csci65/android-vm

In the base directory (e.g. /csci65/android-vm) where the Vagrantfile is located, you should see a hidden .vagrant directory which holds the actual cloned VM files if you are interested in exploring further.

  • To start your vagrant system use,

    For VirtualBox,

      $ vagrant up
    

    For VMware Fusion,

      $ vagrant up --provider=vmware_fusion 
    

    For VMware Workstation

      $ vagrant up --provider=vmware_workstation 
    
  • To login to your vagrant system use,

      $ vagrant ssh
    
  • The basic workflow is,

      $ vagrant up    # To start the VM using VirtualBox (default)
    

or

	$ vagrant up --provider=vmware_fusion     # To start the VM using VMware Fusion (vmware_workstation for Windows users)
		*Spins up the Android VM and loads the Ubuntu Unity desktop UI*
	$ vagrant ssh
		*At this point you are logged into the VM to do the cli work you want to do, e.g.*
		$ lsusb
		$ adb devices
		$ adb shell
		$ adb install
		$ adb push
		$ adb pull
		... for more detail see [http://developer.android.com/tools/help/adb.html]
	
	$ android (from the command line) see [http://developer.android.com/tools/projects/projects-cmdline.html]
	
	$ vagrant status
	$ vagrant halt  # To shutdown the VM

or

	$ vagrant suspend  
  • These are the only commands you will likely use on a regular basis. Vagrant manages everything for you, so there is no need to configure the VM from VMware or Virtual Box except to change the VM memory, CPU allocation, & connect the Android USB device for connection via the Android adb command.

If you are interested in the other options Vagrant offers, please see the man help file using,

$ vagrant --help

References

  1. Vagrant v2 documentation
  2. http://www.vagrantbox.es/
  3. Chef Cookbooks

android-vm's People

Contributors

dweinstein avatar elendrim avatar fschwiet avatar rickfarmer avatar shalecraig avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

android-vm's Issues

Integration of Chef

This is a great project with lots of useful tidbits in it. I am working through the following issue:

Currently the cookbook recipes for:

    apt     
    build-essential     
    git 
    java

are empty. What is the correct way to obtain these chef recipes from the opscode community and integrate them with this project in order to create a functional vagrant configuration. Currently, "vagrant up" with a clone of this repository causes exceptions at these steps.

Error in metadata.rb file of the sqlite-dev chef cookbook used

Hi there,

Just wanted to let you know I had some trouble with the chef cookbooks. The sqlite-dev cookbook causes:
==> default: [2015-01-10T01:51:53+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
==> default: [2015-01-10T01:51:53+00:00] ERROR: Cookbook loaded at path(s) [/tmp/vagrant-chef/b05d38aa2725e9c5a893867ea452ad6b/cookbooks/sqlite-dev] has invalid metadata: The `name' attribute is required in cookbook metadata

To fix the issue, I added the name attribute to the metadata.rb file:
name "sqlite-dev"

I also had trouble with missing cookbooks like yum, yum-epel, windows, runit and dmg. Not sure if I am missing a step or doing something wrong.

Thanks for this great project though : ).

provider expected: virtualbox

I don't have a lot of vagrant experience so sorry if this is a newbish issue. When I run vagrant up, with or without specifying '--provider=virtualbox', I still get an error saying the box is for vmware_fusion. I suspect to fix this I need a different download url.

c:\src\android-vm>  vagrant up

Bringing machine 'default' up with 'virtualbox' provider...
[default] Box 'precise64' was not found. Fetching box from specified URL for
the provider 'virtualbox'. Note that if the URL does not have
a box for this provider, you should interrupt Vagrant now and add
the box yourself. Otherwise Vagrant will attempt to download the
full box prior to discovering this error.
Downloading box from URL: http://files.vagrantup.com/precise64_vmware.box
Extracting box...ate: 11.3M/s, Estimated time remaining: --:--:--)
The box you attempted to add doesn't match the provider you specified.

Provider expected: virtualbox
Provider of box: vmware_fusion


C:\src\android-vm [master]> vagrant up --provider=virtualbox
Bringing machine 'default' up with 'virtualbox' provider...
[default] Box 'precise64' was not found. Fetching box from specified URL for
the provider 'virtualbox'. Note that if the URL does not have
a box for this provider, you should interrupt Vagrant now and add
the box yourself. Otherwise Vagrant will attempt to download the
full box prior to discovering this error.
Downloading box from URL: http://files.vagrantup.com/precise64_vmware.box
Extracting box...ate: 11.3M/s, Estimated time remaining: --:--:--)
The box you attempted to add doesn't match the provider you specified.

Provider expected: virtualbox
Provider of box: vmware_fusion


c:\src\android-vm [master] vagrant up --provider=virtualbox
Bringing machine 'default' up with 'virtualbox' provider...
[default] Box 'precise64' was not found. Fetching box from specified URL for
the provider 'virtualbox'. Note that if the URL does not have
a box for this provider, you should interrupt Vagrant now and add
the box yourself. Otherwise Vagrant will attempt to download the
full box prior to discovering this error.
Downloading box from URL: http://files.vagrantup.com/precise64_vmware.box
Extracting box...ate: 5726k/s, Estimated time remaining: --:--:--)
The box you attempted to add doesn't match the provider you specified.

Provider expected: virtualbox
Provider of box: vmware_fusion

Chef error for sqlite-dev (invalid metadata)

When running "vagrant up --provider=virtualbox" everything seems to go fine until Chef ends in an error. The only warning before this is about different Virtualbox guest additions versions.

Error:
==> default: [2015-11-17T19:32:35+00:00] ERROR: Running exception handlers
==> default: [2015-11-17T19:32:35+00:00] ERROR: Exception handlers complete
==> default: [2015-11-17T19:32:35+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
==> default: [2015-11-17T19:32:35+00:00] ERROR: Cookbook loaded at path(s) [/tmp/vagrant-chef/35cc7da134429f53d1a4d2f5e87e41c0/cookbooks/sqlite-dev] has invalid metadata: The `name' attribute is required in cookbook metadata
==> default: [2015-11-17T19:32:35+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
Chef never successfully completed! Any errors should be visible in the
output above. Please fix your recipes so that they properly complete.

Previous warnings:
"Installing Virtualbox Guest Additions 4.3.32 - guest version is 4.2.0"
and
"Installing the Window System drivers
Could not find the X.Org or XFree86 Window System, skipping.
An error occurred during installation of VirtualBox Guest Additions 4.3.32. Some functionality may not work as intended.
In most cases it is OK that the "Window System drivers" installation failed."

Any idea why this is happening?

errors when trying to run a newly generated android project on eclipse

In order to run a vanilla android project generated by eclipse, I needed to run the solution from http://askubuntu.com/questions/147400/problems-with-eclipse-and-android-sdk:

sudo apt-get update
sudo apt-get install ia32-libs

After this, I needed to restart the VM as well. The error I received before applying the solution is the same as the SO thread (error while loading shared libraries: libz.so.1: cannot open shared object file).

Vagrant up fails

$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
There are errors in the configuration of this machine. Please fix
the following errors and try again:

vm:

  • The following settings don't exist: host_name

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.