def link_android(self, path, pkg):
        """ Link's the android project to this library.

        1. Includes this project's directory in the app's 
            android/settings.gradle
            It adds:
                include ':<project-name>'
                project(':<project-name>').projectDir = new File(
                rootProject.projectDir, '../packages/<project-name>/android')

        2. Add's this project as a dependency to the android/app/build.gradle
            It adds:
                compile project(':<project-name>')
            to the dependencies.

        3. If preset, adds the import and package statement
           to the android/app/src/main/java/<bundle/id>/MainApplication.java

        """

        bundle_id = self.ctx['bundle_id']
        pkg_root = join(path, pkg)

        #: Check if it's already linked
        with open(join('android', 'settings.gradle')) as f:
            settings_gradle = f.read()
        with open(join('android', 'app', 'build.gradle')) as f:
            build_gradle = f.read()

        #: Find the MainApplication.java
        main_app_java_path = join('android', 'app', 'src', 'main', 'java',
                                  join(*bundle_id.split(".")),
                                  'MainApplication.java')
        with open(main_app_java_path) as f:
            main_application_java = f.read()

        try:
            #: Now link all the EnamlPackages we can find in the new "package"
            new_packages = Link.find_packages(join(path, pkg))
            if not new_packages:
                print("[Android] {} No EnamlPackages found to link!".format(
                      pkg))
                return

            #: Link settings.gradle
            if not Link.is_settings_linked(settings_gradle, pkg):
                #: Add two statements
                new_settings = settings_gradle.split("\n")
                new_settings.append("")  # Blank line
                new_settings.append("include ':{name}'".format(name=pkg))
                new_settings.append("project(':{name}').projectDir = "
                                    "new File(rootProject.projectDir, "
                                    "'../{path}/android/{name}')"
                                    .format(name=pkg, path=self.package_dir))

                with open(join('android', 'settings.gradle'), 'w') as f:
                    f.write("\n".join(new_settings))
                print("[Android] {} linked in settings.gradle!".format(pkg))
            else:
                print("[Android] {} was already linked in "
                      "settings.gradle!".format(pkg))

            #: Link app/build.gradle
            if not Link.is_build_linked(build_gradle, pkg):
                #: Add two statements
                new_build = build_gradle.split("\n")

                #: Find correct line number
                found = False
                for i, line in enumerate(new_build):
                    if re.match(r"dependencies\s*{", line):
                        found = True
                        continue
                    if found and "}" in line:
                        #: Hackish way to find line of the closing bracket after
                        #: the dependencies { block is found
                        break
                if not found:
                    raise ValueError("Unable to find dependencies in "
                                     "{pkg}/app/build.gradle!".format(pkg=pkg))

                #: Insert before the closing bracket
                new_build.insert(i, "    api project(':{name}')".format(
                    name=pkg))

                with open(join('android', 'app', 'build.gradle'), 'w') as f:
                    f.write("\n".join(new_build))
                print("[Android] {} linked in app/build.gradle!".format(pkg))
            else:
                print("[Android] {} was already linked in "
                      "app/build.gradle!".format(pkg))

            new_app_java = []
            for package in new_packages:
                #: Add our import statement
                javacls = os.path.splitext(package)[0].replace("/", ".")

                if not Link.is_app_linked(main_application_java, pkg, javacls):
                    #: Reuse previous if avialable
                    new_app_java = (new_app_java or
                                    main_application_java.split("\n"))

                    #: Find last import statement
                    j = 0
                    for i, line in enumerate(new_app_java):
                        if fnmatch.fnmatch(line, "import *;"):
                            j = i

                    new_app_java.insert(j+1, "import {};".format(javacls))

                    #: Add the package statement
                    j = 0
                    for i, line in enumerate(new_app_java):
                        if fnmatch.fnmatch(line.strip(), "new *Package()"):
                            j = i
                    if j == 0:
                        raise ValueError("Could not find the correct spot to "
                                         "add package {}".format(javacls))
                    else:
                        #: Get indent and add to previous line
                        #: Add comma to previous line
                        new_app_java[j] = new_app_java[j]+ ","

                        #: Insert new line
                        new_app_java.insert(j+1, "                new {}()"
                                            .format(javacls.split(".")[-1]))

                else:
                    print("[Android] {} was already linked in {}!".format(
                        pkg, main_app_java_path))

            if new_app_java:
                with open(main_app_java_path, 'w') as f:
                    f.write("\n".join(new_app_java))

            print(Colors.GREEN+"[Android] {} linked successfully!".format(
                  pkg)+Colors.RESET)
        except Exception as e:
            print(Colors.GREEN+"[Android] {} Failed to link. "
                               "Reverting due to error: "
                               "{}".format(pkg, e)+Colors.RESET)

            #: Undo any changes
            with open(join('android', 'settings.gradle'), 'w') as f:
                f.write(settings_gradle)
            with open(join('android', 'app', 'build.gradle'), 'w') as f:
                f.write(build_gradle)
            with open(main_app_java_path, 'w') as f:
                f.write(main_application_java)

            #: Now blow up
            raise
Link's the android project to this library.

        1. Includes this project's directory in the app's 
            android/settings.gradle
            It adds:
                include ':<project-name>'
                project(':<project-name>').projectDir = new File(
                rootProject.projectDir, '../packages/<project-name>/android')

        2. Add's this project as a dependency to the android/app/build.gradle
            It adds:
                compile project(':<project-name>')
            to the dependencies.

        3. If preset, adds the import and package statement
           to the android/app/src/main/java/<bundle/id>/MainApplication.java