Android: Is there way to change the package name of a test package?

Running into the issue when I have my android app installed via sim or device, I will run my automation tests with ‘./gradlew connectedCheck’ and the test package will overwrite the current app installation; then it deletes the instance of the app after the tests are completed.

I want to change the test package name so it does NOT overwrite the current version of the application. Is there a way to do this will Gradle?

1 Like

You can probably get better answer at (linked from

I thought that testing application should have a different package name in its manifest (usually package name of tested app + “.test” suffix). That way the application and its test application can be installed on the device at the same time. And this is what I see when I do ‘gradle assembleTestDebug’ in the generated AndroidManifest.xml for a simple project.

@Radim, Could you show a code example of how you did this in the AndroidManifest.xml?

I was thinking of maybe dynamically changing the package name by overriding the Gradle task

./gradlew connectedCheck
  • don’t know if this is possible or not.

I simply took one of the samples (basic) attached to the bottom of page. If you do not need to set anything special in this manifest you can rely on android build system to generate one for you and that’s what I did. Probably there is an example with an AndroidManifest.xml for testing application as well.

I’m thinking more all the lines of something done here in this post.

‘’’ connectedCheck {

// Change project name + “test” suffix

} ‘’’

Was thinking this could belong in the custom.gradle of my project.