简体   繁体   中英

Generate multiple APK from one single project

I'm trying to understand how i can generate multiple APK from one single project.

I'm using gradle and this is my project's three:

在此处输入图片说明

  • ambrogiocore is the core library module that implements all the common classes and resources.
  • ambrogioremote is the module that has the :ambrogiocore dependence.

It's work. Now i'm able to generate multiple APK. (just one at the moment) One apk for each module.

The problem is that i need to manually sync all the AndroidManifest.xml for every future module that i'll include in my project.

Is this the correct way? Can i automate this operation?

I took a look at productFlavor . Just I don't understand if this tool can help me.

What do you think about?

THANK YOU ALL!

**SOLUTION**

Finally! I found the same solution proposed by @Kai!

Flavor is the way!

This is the best approach for a lots of reasons:

  • Single-module project
  • You don't need to copy XML files
  • RoboGuice will work like a charm . (RoboGuice presents some BIG problem on library projects)

http://www.techotopia.com/index.php/An_Android_Studio_Gradle_Build_Variants_Example

If by " one single source core and multiple project that extends "ProductName", "PackageName" and "resources" " you mean to provide each flavor with unique "ProductName", "PackageName" and "resources", then yes it can be done.

To give each flavor its own unique package, set applicationId for each of your flavors like so:

android {
    productFlavors {
        flavor_1 {
            applicationId = 'com.app.flavor_1'
        }

        flavor_2 {
            applicationId = 'com.app.flavor_2'
        }
    }
}

To give each flavor its own app name and resources, simply put them in a flavor's own directory, Gralde will merge a flavor's resources with your base resources to create a complete one.

For more detail on how Gralde flavors work, please see Gradle Plugin User Guide

This is my final solution!

  • All the common files, manifest and base resources are under "src/main"
  • I moved my projects inside "src/projects"
  • declared two productFlavor (one per project) specifying applicationId and versionName
  • created two sourceSet (one per project) indicating the specific res folder.

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM