Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any way to assemble only one flavor of the androidTest builds?

Tags:

android

I have three flavors in my Android project. How can I build just one of them for my instrumentation tests ("androidTest" build artifact)?

When I run the gradle task assembleAndroidTest with Android Studio 2.0 Beta 2 I get three outputs - one for each of my flavors:

myproject-dev-debug-androidTest-unaligned.apk
myproject-itest-debug-androidTest-unaligned.apk
myproject-production-debug-androidTest-unaligned.apk

What if I just want to build one of them? I don't want to wait 3x the build time for building stuff I don't need (yea it's that bad).

Here is the list of all gradle tasks that contain the name "androidTest":

assembleAndroidTest - Assembles all the Test applications.
compileDebugAndroidTestSources
compileDevDebugAndroidTestSources
compileItestDebugAndroidTestSources
compileProductionDebugAndroidTestSources
compileTelenorDebugAndroidTestSources
installDebugAndroidTest - Installs the android (on device) tests for the Debug build.
installDevDebugAndroidTest - Installs the android (on device) tests for the DevDebug build.
installItestDebugAndroidTest - Installs the android (on device) tests for the ItestDebug build.
installProductionDebugAndroidTest - Installs the android (on device) tests for the ProductionDebug build.
installTelenorDebugAndroidTest - Installs the android (on device) tests for the TelenorDebug build.
uninstallDebugAndroidTest - Uninstalls the android (on device) tests for the Debug build.
uninstallDevDebugAndroidTest - Uninstalls the android (on device) tests for the DevDebug build.
uninstallItestDebugAndroidTest - Uninstalls the android (on device) tests for the ItestDebug build.
uninstallProductionDebugAndroidTest - Uninstalls the android (on device) tests for the ProductionDebug build.
uninstallTelenorDebugAndroidTest - Uninstalls the android (on device) tests for the TelenorDebug build.
connectedAndroidTest - Installs and runs instrumentation tests for all flavors on connected devices.
connectedDebugAndroidTest - Installs and runs the tests for debug on connected devices.
connectedDevDebugAndroidTest - Installs and runs the tests for devDebug on connected devices.
connectedItestDebugAndroidTest - Installs and runs the tests for itestDebug on connected devices.
connectedProductionDebugAndroidTest - Installs and runs the tests for productionDebug on connected devices.
connectedTelenorDebugAndroidTest - Installs and runs the tests for telenorDebug on connected devices.
deviceAndroidTest - Installs and runs instrumentation tests using all Device Providers.
spoonDevDebugAndroidTest - Run all instrumentation tests on all connected devices for 'DevDebugAndroidTest'
spoonItestDebugAndroidTest - Run all instrumentation tests on all connected devices for 'ItestDebugAndroidTest'
spoonProductionDebugAndroidTest - Run all instrumentation tests on all connected devices for 'ProductionDebugAndroidTest'
spoonTelenorDebugAndroidTest - Run all instrumentation tests on all connected devices for 'TelenorDebugAndroidTest'
compileRetrolambdaDebugAndroidTest
compileRetrolambdaDevDebugAndroidTest
compileRetrolambdaItestDebugAndroidTest
compileRetrolambdaProductionDebugAndroidTest
compileRetrolambdaTelenorDebugAndroidTest
like image 513
Nilzor Avatar asked Feb 11 '16 08:02

Nilzor


People also ask

When would you use a product Flavour in your build setup?

You use same core ingredients to make the base but will use different toppings for each one to have a different taste. Similarly, android apps can have the same base functionalities with changes to some of the features like styles, logo etc. This can be achieved using product flavours.

How do I change a variant in build?

NOTE: By default, the Android Studio will generate "debug" and "release" Build Types for your project. So, to change a Build Type, all you need to do is just select your Build Type from the Build Variant and after the project sync, you are good to go.

What is a build type and a product flavor in android?

Build Type applies different build and packaging settings. An example of build types are “Debug” and “Release”. Product Flavors specify different features and device requirements, such as custom source code, resources, and minimum API levels.

What does build type user mean?

Build Type refers to build and packaging settings like signing configuration for a project. For example, debug and release build types. The debug will use android debug certificate for packaging the APK file. While, release build type will use user-defined release certificate for signing and packaging the APK.


1 Answers

If flavor = "flavor" and type = "debug", then try:

./gradlew assembleFlavorDebugAndroidTest
like image 71
Doug Stevenson Avatar answered Oct 30 '22 00:10

Doug Stevenson