dirkvranckaert
dirkvranckaert

Reputation: 1474

Multiple modules with same build type

I have a gradle android project with two modules:

In my gradle configuration I have different build types. The defaults (debug and release, each with custom settings), and dev and beta build type (also with custom signing, custom proguard and custom applicationIdSuffix.

What I now want to do is to build the app package with for example the buildType beta (gradle clean assembleBeta). That starts building the app in beta, sees that it has a dependency to wear, and starts building wear. BUT here's the problem. The wear module is being built with the release build type instead of the same beta-build-type I used to initiate the build.

The custom build type configuration is exactly the same on the two modules, and thus manually building the wear module with beta build type does work. But having a wear module built with beta and packaged inside the app module also built with beta does not work.

Any ideas how I can achieve that?

Upvotes: 2

Views: 3671

Answers (1)

Eugen Martynov
Eugen Martynov

Reputation: 20140

I don't know answer if it is possible to connect/link build variants from one project to another.

But here workaround. You can build app with dependency not to project but to already built apk (https://developer.android.com/training/wearables/apps/packaging.html). So you have to build wear app variant separately and include that artifact to your app artifact.

dependencies {
  ...
  wearApp files('/path/to/wearable_app.apk')
}

UPDATE Actually it is possible:

productFlavors {
        dev {
        }

        prod {
        }
    }
...
devWearApp project(path: ':wearable', configuration: 'devRelease')
prodWearApp project(path: ':wearable', configuration: 'prodRelease')

Credits to Muzei app https://github.com/romannurik/muzei/blob/master/main/build.gradle

Upvotes: 1

Related Questions