Reputation: 4869
I have a UIAutomator test that interacts with the OS to automate some tasks that I can't do from ADB or another app. Sometimes I release a new version of the tests. I planned on using adb shell dumpsys package my.package.test | grep versionName
to parse the version from the test app, and update it if necessary.
However, it appears that dumpsys package
returns versionName=null
for my UIAutomator test (built using a gradle script near-identical to the sample).
Right now I'm just overwriting the test every time I need it. Is there some way to embed version information in a UIAutomator test APK?
Upvotes: 0
Views: 331
Reputation: 69188
There's no version information in the default manifest generated for the test APK, then you have to introduce it.
add this to your build.gradle
:
defaultConfig {
manifestPlaceholders = [ versionName:versionName, versionCode:versionCode]
}
copy your main AndroidManifest.xml
to src/androidTest
edit the test manifest
<!--suppress AndroidDomInspection -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="your.package.name"
android:versionCode="${versionCode}"
android:versionName="${versionName}"
>
<application
tools:node="remove"
... >
</application>
</manifest>
Once rebuilt, your test APK will include version information.
Upvotes: 1