Q:

Android UiAutomator test case jar file is not working

I have been trying to write some instrumental test case of android code using UiAutomator tool. This test cases can be run via android studio without any problem. But now i want to install this test cases into device as a jar file and need to run via command line. I had tried the following link for building and deploying uiautomator tests:
https://stuff.mit.edu/afs/sipb/project/android/docs/tools/testing/testing_ui.html#creating
build.xml is generated but when command "ant build" is executed it shows error:
 Android/Sdk/tools/ant/uibuild.xml:198: null returned: 1

After that i have tried to create jar files using gradle build instead of ant build tool using this link
http://wiliamsouza.github.io/#/2013/10/30/android-uiautomator-gradle-build-system
I have run the "gradle build" command from the project directory and output got;
 Building dex...
 :compileJava UP-TO-DATE
 :processResources UP-TO-DATE
 :classes UP-TO-DATE
 :jar
 :assemble
 :compileTestJava UP-TO-DATE
 :processTestResources UP-TO-DATE
 :testClasses UP-TO-DATE
 :test
 :check
 :build

 BUILD SUCCESSFUL
 Total time: 7.709 secs

but there was no jar file found in "dist" folder. In have installed jar file found in build/libs folder,
adb push sample-0.1.jar /data/local/tmp/

then tried to run the test cases using the command
 adb shell uiautomator runtest sample-0.1.jar -c com.test.uiautomator.sample.Sample

But it shows error as:
   INSTRUMENTATION_RESULT: shortMsg=java.lang.RuntimeException
   INSTRUMENTATION_RESULT: longMsg=Didn't find 
   class"com.test.uiautomator.sample.Sample" 
   on path: DexPathList[[zip 
   file"/system/framework/android.test.runner.jar",
   zip file"/system/framework/uiautomator.jar", 
   zip file"/data/local/tmp/sample-0.1.jar"],
   nativeLibraryDirectories=[/vendor/lib, /system/lib]]
   INSTRUMENTATION_CODE: 0

Is anyone have any idea on this.. how can i create jar files of my uiautomator test cases and how can i run them via command line..?

A:

Got a Solution !!!
Actually my requirement was to run instrumental test cases (UiAutomator in my case)through command line, for this purpose it is not necessary to generate a jar file of the test classes and install them to devices, instead we can create separate apk file of test case package and install them in the same way as application apk file is installed. And then run adb commands for executing the test cases. Please check the below link which has the detailed explanation. 
https://developer.android.com/studio/test/command-line.html#RunTestsCommand 

