Android UiAutomator test case jar file is not working - command-line

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..?

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

Related

yocto opendds does not create the sdknative files

I am trying to build an application that communicates with dds with opendds. I am using the opendds layer on krikstone. The bitbake image is built with the opendds libraries but when I build the sdk it seems the layer nativesdk is not installed. When I run the cmake I get the error "Missing required dependencies OPENDDS_IDL;ACE_GPERF;TAO_IDL".
from the opendds.inc I see there is the nativesdk install. I added a junk line and expected that when i build the opendds or build the populate-sdk I will fail but it seems that the nativesdk is not run.
build is for imx8mm variscite som with command bitbake fsl-image-qt5 -v populate_sdk_ext
layer with the problem is meta-opendds (krikstone branch) building version 3.22
the layer has a bb file that requires an opendds.inc file which has the nativesdk install
Blockquote
do_install:append:class-nativesdk() {
dfdf -- my junk line to trigger failure
ln -sf ${bindir}/opendds_idl ${D}${datadir}/dds/bin/opendds_idl
ln -sf ${bindir}/ace_gperf ${D}${datadir}/ace/bin/ace_gperf
ln -sf ${bindir}/tao_idl ${D}${datadir}/ace/bin/tao_idl
}
Blockquote
** i added a junk line to trigger failure but it doesnt fail with building the sdk or image itself
why is the nativesdk command not run and why is the sdk without the opendds_idl executable
thanks
I was able at last to build the nativesdk files. I had to build them specifically as they are not build by default. i had to "bitbake nativesdk-opendds" manually.
my mistake was to believe that the nativesdk will be defaulted. my assumption is that if i am using the opendds that most probable that i will build subscribers/produces applications and will need the opendds_idl executable.
!!!! after testing the nativesdk-opendds it did not solve the problem !!!
!! in general after adding building the opendds layer i cannot build the Messanger example for lack of the opendds_idl and other two (tao,ace) executable

JDK installation not found by flutter starter app

I have cloned the flutter repo and installed the Android SDK command-line tools, setting them up in $HOME/Android. I then made flutter aware of the SDK installation by setting $ANDROID_HOME to $HOME/Android. Things seem to have worked out, with <path-to-flutter> doctor finding
Android SDK
my Java JDK 8 installation (openjdk-8-jdk package on Ubuntu 18.04), and
a connected Android phone with USB debugging
I am now trying to follow the test-run instructions for building a first app on the command line. <path-to-flutter> create myapp works and produces a myapp directory. I then try to run the resulting starter app:
cd myapp
~/myapp$ ANDROID_HOME=~/Android JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64 <path-to-flutter> run
This results in the following error:
Launching lib/main.dart on ONEPLUS A6013 in debug mode...
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDebugKotlin'.
> Kotlin could not find the required JDK tools in the Java installation '/usr/lib/jvm/java-8-openjdk-amd64/jre' used by Gradle. Make sure Gradle is running on a JDK, not JRE.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 10s
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... Done 11.0s
Exception: Gradle task assembleDebug failed with exit code 1
I have seen this issue discussed before, but none of those replies seem to address it (in my case, at least). You can see from the command that I am exporting the right $JAVA_HOME, and besides, running
./android/gradlew build
inside the myapp directory does work:
~/myapp$ ./android/gradlew build
> Task :buildEnvironment
------------------------------------------------------------
Root project
------------------------------------------------------------
classpath
No dependencies
A web-based, searchable dependency report is available by adding the --scan option.
BUILD SUCCESSFUL in 319ms
1 actionable task: 1 executed
So this seems to be specific to flutter itself somehow, rather than gradle.
It turns out this must have been a path issue. The Flutter starter app builds (and pops up on my device) after inserting the following snippet in a file sourced in my profile (my .bashrc):
# Java
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64
# Android
export ANDROID_HOME=${HOME}/Android
export ANDROID_SDK_ROOT=${HOME}/Android
# Flutter
export FLUTTER_HOME=${HOME}/repos/flutter
PATH=${FLUTTER_HOME}/bin:$PATH; export PATH
you can do like this -->
sudo apt-get remove --auto-remove openjdk*
sudo apt-get install openjdk-8-jre
now goto to home and visible your hidden folder by pressing ctrl+h
Now open .bashrc or your .rc
paste these on last
export PATH="$PATH:/snap/bin/flutter/bin"
export PATH="$PATH:/usr/bin/java"
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64/jre
export ANDROID_SDK_ROOT=/home/<YOUR USER NAME>/Android/Sdk
then run
source ~/bashrc
flutter doctor -v

CakeBuild: Get failed to install tool 'NUnit.ConsoleRunner'

I used CakeBuild to build and test my Xamarin Portable Class Library.
In the build.cake script I defined that I want to use the NUnit-Console to run my testcases. So I do
#tool nuget:?package=NUnit.ConsoleRunner
Unfortunatelly I get the following error when I run the Cake script.
Preparing to run build script...
VERBOSE: Restoring tools from NuGet...
VERBOSE: Feeds used:
C:\Users\bergkar\.nuget\packages\
All packages listed in C:\dev\Xamarin\fleetboard-core-library\tools\packages.config are already installed.
Running build script...
Analyzing build script...
Processing build script...
Installing tools...
Unable to find package 'NUnit.ConsoleRunner'
NuGet exited with 1
Could not find any relevant files for tool 'NUnit.ConsoleRunner'. Perhaps you need an include parameter?
Error: Failed to install tool 'NUnit.ConsoleRunner'.
When I add a specific version I want to use like below then everything works fine.
#tool nuget:?package=NUnit.ConsoleRunner&version=3.7.0
Can someone tell me why it is not working without the version stuff?
With ".\build.ps1 -Verbosity Diagnostic" I get the following output:
Preparing to run build script...
Running build script...
Module directory does not exist.
Analyzing build script...
Analyzing C:/dev/Xamarin/fleetboard-core-library/build.cake...
Processing build script...
Installing tools...
Installing NuGet package NUnit.ConsoleRunner...
Executing: "C:/dev/Xamarin/fleetboard-core-library/tools/nuget.exe" install "NUnit.ConsoleRunner" -OutputDirectory "C:/d
ev/Xamarin/fleetboard-core-library/tools" -ExcludeVersion -NonInteractive
Unable to find package 'NUnit.ConsoleRunner'
NuGet exited with 1
Feeds used:
Output:
Feeds used:
Could not find any relevant files for tool 'NUnit.ConsoleRunner'. Perhaps you need an include parameter?
Error: Cake.Core.CakeException: Failed to install tool 'NUnit.ConsoleRunner'.
at Cake.Core.Scripting.ScriptProcessor.InstallTools(ScriptAnalyzerResult analyzerResult, DirectoryPath installPath)
at Cake.Core.Scripting.ScriptRunner.Run(IScriptHost host, FilePath scriptPath, IDictionary`2 arguments)
at Cake.Commands.BuildCommand.Execute(CakeOptions options)
at Cake.CakeApplication.Run(CakeOptions options)
at Cake.Program.Main()
Now I found my problem and solved it.
The problem was that the NuGet.exe did not has a source feed which points to a public nuget source like "https://api.nuget.org/v3/index.json".
This was because my default NuGet.conf in under "C:\Users\YOUR_USER_HOME\AppData\Roaming\NuGet" had no packageSource defined. So Nuget just knows the local nuget package cache under "C:\Users\YOUR_USER_HOME.nuget\packages" and this did not include the specified package.
So after I added a packageSource in "C:\Users\YOUR_USER_HOME\AppData\Roaming\NuGet\NuGet.Conf" everything works fine.
Another way can be to add a new NuGet.Conf beside your build.ps1 file which contains all package sources you need for CakeBuild and your Xamarin project.
The following page explains how Nuget finds its configuration. Maybe this is helpful to understand the mechanism NuGet uses to find its configuration:
https://learn.microsoft.com/en-us/nuget/consume-packages/configuring-nuget-behavior

Intel XDK Google + google services plugin - build fails

I have developed a working hybrid application in which I am using "phonegap-googlemaps-plugin". This plugin needs as a dependency two other which downloads and installs automatically in the project. The dependencies are:
com.google.playservices and plugin.http.request
Using the Cordova-CLI, installing this plugin with the dependencies will fail building the project the 1st time because of a specific directory in the "playservices" plugin. To overcome this, I have to run "ant clean" in my project and also remove/rename that directory. Now, I am using Intel XDK and uploaded my app and installed most of my plugins successfully and run the application on my device. When I am trying to install the google play services plugin, it fails to build because of the reason I described above (I've run through the logs). How can I overcome this issue now?
I have attached the part of the log that shows the fail error
[mergemanifest] Merging AndroidManifest files into one.
[mergemanifest] Manifest merger disabled. Using project manifest only.
[echo] Handling aidl files...
[aidl] No AIDL files to compile.
[echo] ----------
[echo] Handling RenderScript files...
[echo] ----------
[echo] Handling Resources...
[aapt] Generating resource IDs...
[aapt] invalid resource directory name: .../App/platforms/android/com.google.playservices/google-play-services_lib/bin/res/crunch
BUILD FAILED
/Developer/android-sdk-linux/tools/ant/build.xml:653: The following error occurred while executing this line:
/Developer/android-sdk-linux/tools/ant/build.xml:698: null returned: 1
Total time: 5 seconds
Error code 1 for command: ant with args: release,-f,.../App/platforms /android/build.xml,-Dout.dir=ant-build,-Dgen.absolute.dir=ant-gen
Command finished with error code 2: .../App/platforms/android/cordova/build --release
Error: .../App/platforms/android/cordova/build: Command failed with exit code 2
at ChildProcess.whenDone (/Developer/cordova/3.5.0-0.2.7/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:135:23)
at ChildProcess.EventEmitter.emit (events.js:98:17)
at maybeClose (child_process.js:743:16)
at Process.ChildProcess._handle.onexit (child_process.js:810:5)
Thanks in advance.

Netbeans cannot create build/create cordova application

I try to create a sample Cordova project in Netbeans after starting an Android emulator.
This is exactly what I am getting when I run the project:
cordova.cmd -d create C:\DOCUME~1\user\LOCALS~1\Temp\/nb_temp_project com.coolappz.Cordova Cordova
Creating a new cordova project with name "Cordova" and id "com.coolappz.Cordova" at location "C:\DOCUME~1\user\LOCALS~1\Temp\nb_temp_project"
Using stock cordova hello-world application.
cordova library for "www" already exists. No need to download. Continuing.
Copying stock Cordova www assets into "C:\DOCUME~1\user\LOCALS~1\Temp\nb_temp_project\www"
Copying 6 files to C:\Documents and Settings\user\My Documents\netbeans7.41projects\Cordova
Deleting directory C:\DOCUME~1\user\LOCALS~1\Temp\nb_temp_project
Deleting directory C:\Documents and Settings\user\My Documents\netbeans7.41projects\Cordova\www
Copying 13 files to C:\Documents and Settings\user\My Documents\netbeans7.41projects\Cordova\www
create-android:
cordova.cmd -d platform add android
cordova library for "android" already exists. No need to download. Continuing.
'C:\Documents' is not recognized as an internal or external command,
Checking if platform "android" passes minimum requirements...
Creating android project...
Running command: cmd args=["/c","C:\\Documents and Settings\\user\\.cordova\\lib\\android\\cordova\\3.4.0\\bin\\create","--cli","C:\\Documents and Settings\\user\\My Documents\\netbeans7.41projects\\Cordova\\platforms\\android","com.coolappz.Cordova","Cordova"]
Command finished with error code 1: cmd /c,C:\Documents and Settings\user\.cordova\lib\android\cordova\3.4.0\bin\create,--cli,C:\Documents and Settings\user\My Documents\netbeans7.41projects\Cordova\platforms\android,com.coolappz.Cordova,Cordova
operable program or batch file.
C:\Documents and Settings\user\My Documents\netbeans7.41projects\Cordova\nbproject\build.xml:145: exec returned: 1
BUILD FAILED (total time: 5 seconds)
First, try to run your project in web browser before you build in Android application. If there is no error or bug, then compile the project to Apk. you have to connect internet while in progress