there's no ./gradlew command to launch the app, right? - android

I'm too lazy to reach out and tap the application icon on my tablet. After installing and testing, how do I tell ./gradlew to launch the app? This command returns nothing:
$ ./gradlew tasks --all | grep -i launch
A related question that might fix my ulterior problem is: How to write an Android app that prefers to be on all the time? My app is in-house, so our tablets have no reason to exist except to run our app.

Per CommonsWare's comment, try:
adb -s WHATEVER shell am start -n com.mycorp.myapp/com.mycorp.myapp.MainActivity
and forget gradlew because I have all my command lines in a Rakefile already because it's easy to maintain.

Related

ADB command to resume android app to foreground without knowing activity

I want to bring a background application to the foreground by its package name without knowing the current activity.
You can achieve this by calling driver.activateApp(package-name); see this for more details
Yes. It's possible to run application specifying package name only using monkey tool by follow this pattern:
adb shell monkey -p your.app.package.name -c android.intent.category.LAUNCHER 1
Command is used to run app using monkey tool which generates random input for application. The last part of command is integer which specify the number of generated random input for app. In this case the number is 1, which in fact is used to launch the app (icon click).
More simplify version of adb command:
android.intent.category.LAUNCHER is default as it is part of Andriod OS. so You can simplify it
adb shell monkey -p your.app.package.name 1
Hope it will help you.

Test app in android phone using command line?

Android Studio is running quite slow in my laptop so Im planning use Android Studio just for building the app structure and use Sublime Text 3 for coding, but I want to test my app in my phone connected via USB using a command within the terminal. ADB maybe? or something else?
you can push the apk and install using adb install.
Of course, you still need to compile the new APK each time.
To run your tests from the command line use am instrument. For example to run all tests in your package:
$ adb shell am instrument -w com.example.foo/android.test.InstrumentationTestRunner
assuming your application package name is com.example.foo and is using InstrumentationTestRunner.
To verify your test package is installed, run
$ adb shell pm list instrumentation
EDIT
Or, if you just want to run the app once installed
$ adb shell am start -n com.example.foo/.MainActivity

AppleScript "do shell script" ignores PATH Variable

I'm trying to build an automated build script with applescript on MacOS X.
For now everything works correctly with one glitch.
The command "do script ("zipalign -f -v 4 /tmp/src.apk /tmp/tgt.apk") works fine if I run it in a separate tell for application "Terminal" but leaves the terminal window open when it's done. Everything else in the script works fine in tells for application "Finder".
If I try to run the command via "do shell script" inside the tell for "Finder" I only get an error "command not found".
The path to zipalign is set in /etc/paths and is reachable through any terminal window and "do shell" but not to "do shell script" command.
What is the correct way to ensure that "do shell script" uses $PATH to find commands or alternatively is there a bulletproof way to close the terminal left by "do script"?
When you invoke bash as an interactive login shell, the paths in /etc/paths and /etc/paths.d/* are added to PATH by /usr/libexec/path_helper, which is run from /etc/profile. do shell script invokes bash as sh and as a non-interactive non-login shell, which does not read /etc/profile.
You can run path_helper manually though:
do shell script "eval `/usr/libexec/path_helper -s`; echo $PATH"
Though this question was four years ago, but I think the simplest answer is needed to be told. I use the command 'wkhtmltopdf' (which is used to print pdf and it is placed in /usr/local/bin) for example
--past
wkhtmltopdf out.html out.pdf
--now
PATH=$PATH:/usr/local/bin; wkhtmltopdf out.html out.pdf
It just add new PATH variable to the sh process called up by AppleScript.

Is it possible to install APK file if more than one emulators/devices are connected [duplicate]

This question already has answers here:
How to use ADB Shell when Multiple Devices are connected? Fails with "error: more than one device and emulator"
(15 answers)
Closed 7 years ago.
I know how to install the apk file in to the emulator by command prompt and all that.
But i want to know is it possible to install same apk file in to multiple emulator by giving any specific name ?
Actually i have to test one apk file in to many device. and for that i have started many device. I know how to install it. if the all device are open then it will not get install. So is there any alternate to install that apk file by giving any specific device Emulator id or any name ???
Please help me if there is any idea for it. . .
Thanks.
Yes, you can install an apk on a particular device.
In command, type:
adb devices
// list of devices and its unique ID...
Then type:
adb -s "<deviceIDfromlist>" install "<path-to-apk>"
Step 1: Get the device Ids of all connected device
adb devices
Step 2: Install to a particular device you want to install
adb -s deviceId install path+apk
Example:
Step 1:
C:\Android\android-sdks\platform-tools>adb devices
List of devices attached emulator-5554 device 014FD87107021017
device
Step 2:
C:\Android\android-sdks\platform-tools>adb -s 014FD87107021017 install C:\Users\
user\Documents\appname.apk
Use the following scripts to install apk on multiple devices/emulators.
for SERIAL in $(adb devices | grep -v List | cut -f 1);
do adb -s $SERIAL install -r /path/to/product.apk;
done
Remove -r if you are not reinstalling the apk. Also you can replace "install -r /path/to/product.apk" to other adb commands like working on one single device.
It works for me on real devices but I believe it should also works for emulators.
It is possible to issue install command simultaneously on all connected devices.
The key is to launch adb in a separate process (&).
I came up with the following script to simultaneously fire-off installation on all of the connected devices of mine and finally launch installed application on each of them:
#!/bin/sh
function install_job {
adb -s ${x[0]} install -r PATH_TO_YOUR_APK
adb -s ${x[0]} shell am start -n "com.example.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
}
#iterate over devices IP-addresses or serial numbers and start a job
while read LINE
do
eval x=($LINE)
install_job ${x[0]} > /dev/null 2>&1 &
done <<< "`adb devices | cut -sf 1`"
echo "WATING FOR INSTALLATION PROCESSES TO COMPLETE"
wait
echo "DONE INSTALLING"
Note 1: the STDOUT and STDERR are suppressed. You won't see any "adb install" operation result. This may be improved, I guess, if you really have to
Note 2: you could also improve script by providing args instead of hardcoded path and activity names.
That way you:
Don't have to manually perform install on each device
Don't have to wait for one install to finish in order to execute another one (adb tasks are launched in parallel)
yes you can install your apk file in multiple emulator for that you have to give the name in command prompt here is the link for guidance
http://developer.android.com/guide/developing/tools/emulator.html
You can install on multiple devices at a time using USB debugging.
In Eclipse
Run--> Run Configurations --> choose your project (on left) -->Target --> Launch on All compatible devices.
The selected project will be installed on all the connected devices

Ideas for automating Android Monkey runs

I currently use the Android Monkey tool for stress testing Android system/packages. I find it to be useful. But so far everything has been manual testing (i.e. open emulator, execute adb shell monkey <...>, etc.). I'd like to "automate" this and have it triggered externally by a build server.
My initial instinct is to just write a shell script to execute monkey (using random seeds) and then store the results in an build server accessible file. But is this really useful?
Just curious if anyone has done this before and/or has a "smarter" idea for automating Android Monkey runs. A Google search using terms "automating android monkey" turned up little relevant information.
All thoughts welcome.
Update:
I decided to go with a simple shell script since I couldn't think of anything "smarter" to do. It's still a work in progress. Here it is at it's current state:
#!/bin/bash
REPORTROOT=./reports
# remove old report files
echo "Removing old output report files..."
rm $REPORTROOT
# make dir for new report files
echo "Output reports will be stored in $REPORTROOT..."
mkdir $REPORTROOT
# run monkey on the entire system
echo "Running Monkey on entire system..."
adb -e shell monkey -v -v -v 500 > $REPORTROOT/monkey_sys.txt
# pull the log file from device?
# run monkey on particular packages
# packages here...
# create composite report
echo "Running reports..."
grep -A 5 -h -r CRASH $REPORTROOT > $REPORTROOT/crash_report.txt
The output is a simple .txt file with a few lines about any crashes.
You could look at Hudson - that should be able to start an emulator and then do your android monkey commands.

Categories

Resources