I successfully migrated my project from eclipse to android studio and the default build.gradle file was created. The project is building correctly, and I can deploy it for debugging, etc.
The real problem is creating the release APK files (from the command line) for which I had custom ant -build (called via the command line, not from eclipse).
My custom build.xml file imported the standard sdk build.xml file from the SDK folder with:
<import file="${sdk.dir}/tools/ant/build.xml" />
So, all I had to do in my build.xml file was to redefine the goals or connect to them through the "depends".
Override Example:
<target name="-set-release-mode" depends="-set-mode-check"> </target
And an example of adding dependencies:
<target name="-pre-build" depends="clean"> </target
So the common thing was really simple using ant. But now, when it comes to switching to gradle, I am in a complete loss of how to accomplish what I did earlier in ant, in particular:
- There is a default build.xml file in the build.xml file that I imported in my ant assembly, somewhere there is a standard build.gradle file, so can I check for specific tasks?
- Is it possible to override gradle tasks, and if so: how?
- I'm pretty sure that depend = "..." from ant can be mimicked in gradle, but I have no idea how to do this, I also need the answer to question 1.
I googled a bunch of tutorials, as well as migration tutorials, sort of (unfortunately not affecting my problems):
http://keepsafe-engineering.tumblr.com/post/87818767721/migrating-android-app-from-ant-to-gradle
http://ryanharter.com/blog/2013/07/17/migrating-android-projects-to-gradle/
I also read this chapter from gradle docs that really didn't help at all, because it doesn't answer question 1 or 2 or 3:
http://www.gradle.org/docs/current/userguide/ant.html
Below are some interesting pointers:
http://toastdroid.com/2014/03/28/customizing-your-build-with-gradle/
I also tried just copying the default build.xml file from the sdk folder to my own build.xml file and then just import this ant build file into gradle and execute the ant task that starts the build:
<target name="release" depends="-set-release-mode, -release-obfuscation-check, -package, -post-package, -release-prompt-for-password, -release-nosign, -release-sign, -post-build" description="Builds the application in release mode."> </target>
but I began to run into problems that suggested that this was no longer an option, because by default build.xml started throwing errors that seemed to be related to the SDK version. And I had to mess around a lot with the original sdk build.xml due to the new structure of the Android studio project, so the files were not where they were expected, etc ....