Deploy and autorun Android application from Git - android

I have some number of Android devices in real world, I want to deploy and run new versions of application from git on it.
Currently I use Bitrise to run tests and .apk compilation upon commits, how can I deploy that binaries on my devices and autorun it without user interaction?
I don't know such services/application, but I think there are such services/tools in the world, just I don't know about it.
Edit 1:
My devices are not connected physically, so I can't run gradle to deploy new builds there, devices have access to internet, but they have no direct cable connection to build server.

If your devices connected to CI build machine you need setup execution:
get device list adb devices
1.1 Install app with gradle like "./gradlew installDebug"
1.2 Install app with adb "adb -s your_device install your_app.apk"
Then run specific activity "adb -s your_device shell am start -n com.package.name/com.package.name.ActivityName"
You can write shell script or even create gradle task for this.

Related

Testing changes made to AOSP code (package android.media) on an emulator

I downloaded AOSP on Ubuntu, made changes and built it for x86_64 (lunch aosp_x86_64-eng).
The changes are in package android.media.
Can I test the changes on the emulator on Ubuntu? Do I need to build the emulator?
(I am not using Android Studio. I build AOSP and start the emulator on the command line.)
Option 1: the framework and push the jar
make framework
adb root
adb remount
adb sync
adb reboot
Option 2:
Full make and flash via fastboot

Install application and espresso test apk and run on device

I am very new to android and learning it for the first time.
On my android project, when I do
gradle build
gradle assembleDebugAndroidTest
I get the application and test apks
So I have these two questions
1) How do I install them on a specific connected device/emulator?
2) How do I start the tests to run on the device ?
Thanks very much.
Run adb devices to see your connected devices:
List of devices attached
emulator-5554 device
emulator-5556 device
Then, use ANDROID_SERIAL to specify the one you want.
To install:
ANDROID_SERIAL=emulator-5554 gradle installDebug
To run tests:
ANDROID_SERIAL=emulator-5554 gradle connectedAndroidTestDebug

Which adb commands does eclipse use to run app?

I'm working on an app that uses device admin. If I run the app on a device using eclipse, then make a minor change to the code, then run the app again, the app runs as you'd expect with the new change.
However, if the second time I run the app I use adb install I get:
Failure [INSTALL_FAILED_ALREADY_EXISTS]
If I try to uninstall then reinstall, the uninstall fails because the app is device admin. This has led me to wonder which adb commands eclipse executes when you select run. I've looked for some sort of "update" command but I couldn't find one. Anyone know?
You can use "adb install -r yourapp.apk" to install your system apk again.
If you want to run through command line, use
"adb shell am start -n acticityname_withpackage"

What is the ADB?

I keep reading tutorials where I'm supposed to enter something into the ADB command line and that it's in my Android sdk/platform-tools. So I find it, click on it, and a black screen comes up for about 2 seconds and while it's up, it scrolls through a bunch of text. So how am I supposed to use this "adb"?
It is called the Android Debug Bridge, and the Android Developers Site documentation does a better job of explaining it than I can:
http://developer.android.com/guide/developing/tools/adb.html
If you are looking for the adb command line, navigate to <sdk>/platform-tools/ and run
adb.exe shell
from the command line.
Pretty sure that is well documented since day 1 on the Android Debug Bridge
Android Debug Bridge (adb) is a versatile command line tool that lets
you communicate with an emulator instance or connected Android-powered
device. It is a client-server program that includes three components:
A client, which runs on your development machine. You can invoke a
client from a shell by issuing an adb command. Other Android tools
such as the ADT plugin and DDMS also create adb clients. A server,
which runs as a background process on your development machine. The
server manages communication between the client and the adb daemon
running on an emulator or device. A daemon, which runs as a background
process on each emulator or device instance.
So plain old English, ADB can be found on %ANDROID_HOME%/platform-toos/, and it's this magical command line that allows you to comunicate with your mobile device, either a physical or a Virtual device (AVD), so whenever you deploy you are passing the application through the device thanks to the ADB on a specific client port on your computer to the daemon port on the device.
Interesting things you can do with it?
Logcat: ./adb logcat allows you to see the log trace of each proces.
Install: ./adb install allows you to install apk to the device.
Killing:./adb kill-sever
Starting:./adb stat-server
Enter SQLite3: adb -s your_device shell
Use the monkey: adb shell monkey -v -p your.app.package 500 to
generate random events
And a lot more! Read the documentation it's beatiful and self-explanatory.

Can we run Instrumentationtestcases on android phone without it being connected to the PC?

I wrote some test cases for a standard browser app using instrumentationtestcase packages for an android phone.
i am able to run the tests when the phone is connected to pc ..
is there a way to include these test cases in the app in such a way that these test cases are run when an activity is invoked!!
thanks in advance
You could use something like Adb Wireless (requires root) which lets you run and test your applications (from the IDE) but without having a cable.
If what you want is running tests by invoking something from the device... then I don't know if it's possible. But at least it seems very useless... what's the point of running JUnit tests if you cannot see what failed?
I would say yes if I have understood your question correctly.
There is "Dev Tools" available in Android emulator. You just need to create emulator in Eclipse. Then you need to fetch/install this application from emulator to your connected device. After that you install your test project in your device. Then you will be able to run that test project independent of your PC by selecting it from Instrumentation menu option of Dev Tools.
Following are the commands (you can change paths accordingly):
To copy from a running emulator to connected device, execute:
adb -e pull /system/app/Development.apk ./Development.apk
To copies the .apk file into the current directory. Then install it on your connected device with:
adb -d install Development.apk
Hope this was your problem and required solution.

Categories

Resources