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 http://groups.google.com/group/adt-dev (linked from http://tools.android.com/tech-docs/new-build-system/).

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 http://tools.android.com/tech-docs/new-build-system 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.http://forums.gradle.org/gradle/topics/how_do_i_override_an_existing_task

‘’’ connectedCheck {

// Change project name + “test” suffix

} ‘’’

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