Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I find two gradle android plugin - Is there any relation between the two?

I was trying to find out how to build Android application with Gradle. To my surprise I found two references, one from jvoegele and another from Android Tools Project site. They appear to be different prima facie. So my question is why there are two variants? Is there any relation between the two? What are their current status? Which one I should use - their pros and cons? It seems the Android one is just started.

I am looking forward to some valuable inputs from guys who have first hand experience in building Android application with Gradle.

Thanks and regards

Santanu

like image 200
Santanu Avatar asked Nov 11 '12 15:11

Santanu


2 Answers

I just playing around with the gradle plugin from the android tools project site and it feels quite hard to figure out how things should work. It is not very good integrated into the eclipse development work flow, even default project configuration for eclipse did not work for me. It is possible to fix this by extending the project and classpath file creation and modifying the project layout inside the gradle build file.

For fixing the eclipse project creation I got inspired by the plugin from jvoegele (credits go there):

eclipse{
    project {
        natures "com.android.ide.eclipse.adt.AndroidNature"

        def builders = new LinkedList(buildCommands)
        builders.addFirst(new BuildCommand("com.android.ide.eclipse.adt.PreCompilerBuilder"))
        builders.addFirst(new BuildCommand("com.android.ide.eclipse.adt.ResourceManagerBuilder"))
        builders.addLast(new BuildCommand("com.android.ide.eclipse.adt.ApkBuilder"))
        buildCommands = new ArrayList(builders)
    }
    classpath {
        containers.removeAll { it == "org.eclipse.jdt.launching.JRE_CONTAINER" }
        containers "com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"

        plusConfigurations += configurations.compile

        file {
            whenMerged { classpath ->
                classpath.entries.removeAll { it instanceof SourceFolder && (it.dir?.path == "gen" || it.dir?.path == "src") }
                classpath.entries.add(new SourceFolder("gen", null))
                classpath.entries.add(new SourceFolder("src", null))
            }
        }
    }
}

If you want to get your project fast to be productive, this is plugin not suitable for you.

like image 133
0x0me Avatar answered Nov 03 '22 17:11

0x0me


The original Android gradle plugin by jvoegele is no longer supported, but the gap in features between com.android.tools.build plugin is shrinking.

like image 25
Seth Rylan Avatar answered Nov 03 '22 16:11

Seth Rylan