2

I'm just getting my first steps using Gradle on android projects,just can i know if it's possible to generate two apk with different app names , and SAME resources ,using gradle. to concreticize more : i want to compile a Helloworld project , and generate 2 apk with different names. is it possible and how ?

thanks .

wissem46
  • 393
  • 3
  • 5
  • 14

1 Answers1

2

Yes, using the product Flavors mechanism.

You'll write:

android {
  productFlavors {
    flavor1 {
      packageName "com.my.package.name.1"
    }
    flavor2 {
      packageName "com.my.package.name.2"
    }
  }
}

With all your sources in the default source folder (src/main/java) and the default manifest (src/main/AndroidManifest.xml), you'll automatically get 2 apps which only differ in the package name in their manifest.

Documentation: http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants

Xavier Ducrohet
  • 28,383
  • 5
  • 88
  • 64
  • well ,that resolved my problems ,the documentation was so helpful,i created two different small apps : free and paid version, i used also this tutorial , and that helped me alot http://www.youtube.com/watch?v=7JDEK4wkN5I – wissem46 Mar 20 '14 at 15:07