How to change application's package name dynamically in a gradle task?


(kris.j.smith14) #1

I am overriding the task:

connectedCheck {
  }

in my application’s build.gradle.

I want to change the package name when this task is ran so I can have two instances of my application on device during testing, one for automation/unit tests and one for just installing the app normally. Currently, when i run ./gradlew connectedCheck, it overwrites the current app install, and deletes itself when finished.

I have tried.

manifest.attributes(["package":"com.webfilings.webfilings.test"])

(Radim Kubacki) #2

You are wrestling with the default behavior of ‘android’ plugin described in http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Running-tests that wants to install the app, test it and uninstall the app. IMO there is a risk that whatever you find can break with their next update because it is still under development.

Can’t you just create a flavor for these instrumented tests and run {{./gradlew connectedInstrumentTestDebug}} ? The flavor can get its own package name.


(kris.j.smith14) #3

thanks for the answer. (side note, how would I delete this question?)


(Luke Daley) #4

Do you need to for security reasons? We generally don’t delete anything unless there’s a security/privacy concern.


(kris.j.smith14) #5

yes, for security reasons.