2

I’m using Android Studio and Gradle.

There are some flavors that having a little differrent views and features.

So, for each flavor, I want to switch Android.mk1 file.

ex)

  • flavorA -> Android_flavorA.mk
  • flavorB -> Android_flavorB.mk

but, in externalNativeBuild and ndkBuild block, couldn’t dynamically change a path of Android.mk.

Anybody know about this?

1 Answers1

5

Rather than having separate makefiles you could pass the product flavor to your makefile:

In app/build.gradle:

productFlavors {
    flavor1 {
        externalNativeBuild {
            ndkBuild {
                arguments "PRODUCT_FLAVOR=flavor1"
            }
        }
    }
    # etc...
}

In Android.mk:

ifeq (flavor1,$(PRODUCT_FLAVOR))
    # Do flavor-specific stuff
endif

I suppose the Do flavor-specific stuff-part could be an include if your flavor-specific parts are very large.

Michael
  • 57,169
  • 9
  • 80
  • 125