I m using console tools to build my android application. To do it, I use:
ant debug
adb install bin/MyApp.apk
and then I have to choose an aplication from menu in emulator. Is it possible to run already installed application in emulator with console command?
I think you can use the am option in adb. I will try and find it in the manual if I have time, but maybe this will be enough for you to start?
This looks like a good start with some examples on how to start stuff from the commandline:
http://www.anddev.org/using_the_am-tool_start_activities-intens_from_a_shell-t368.html
You can start a specific activity like this:
adb shell am start <INTENT>
To find out how to pass the intent, type adb shell am
Related
I am new to Android development. I have been going through the tutorials.
I would like to know which is the right way to debug / log an application during its execution. I am guessing I should be able to execute my application directly on my android device and be able to view a log or so to catch runtime errors and logs?
How could I accomplish this ?
I am using this to install the application on my phone
adb install <path to apk>
p.s. I am sure this question might seem like something I should already know. But I could not figure it out :) Hence I am here :)
You can build on the command line with ant. See this guide.
& install it by using adb on the command line.
adb install MyApp.apk
path of apk with file extension
update
for getting logcat or crash report
do this way:
adb logcat
note: make sure only one device is connected to adb bridge
for filtering:
check this & this.
I used ant to build my Eclipse project from the command line in a debug configuration. (Eclipse Luna and Android NDK-R10d is broken, so I can't use Eclipse any longer. Confer, Eclipse/ADT plugin cannot locate symbols for r10d NDK).
I then performed an install using adb:
<Project Directory>$ adb install bin/AndroidPrng-debug.apk
When I rummage for the program on the device in Apps, the program is not offered. When I attempt to search for it by name on the device (AndroidPrng and com.example.prng), I'm provided with useless web search results. When I go to Settings → Apps, the app is shown under the Downloaded tab (it shows the name as com.example.prng). It has the familiar Force Stop and Uninstall.
I have DDMS running and waiting to capture LogCat output from the program. But even though the app is on the device, I cannot figure out how to run it.
How do I run and debug the app when it does not show up under Apps?
Assuming that your app do have an Activity from where you can navigate into other parts of your app.
Try using below command:
$ adb shell am start -n com.example.yourpackagename/.YourMainActivity
or $ adb shell am start -n com.package.yourpackagename/com.example.yourpackagename.YourMainActivity
This am start command, is a command-line interface to the ActivityManager.
I want to use ECLIM plugin for VIM during android development.
The main problem : I can't run my project from eclim, so I can't see logs and errors.
I know such command :
:Ant debug install
This command compiles and updates my project to connected device. I have to run it manually.
I'm not lazy, and is not problem to run it.
But I wish to see runtime's Logs.:)
open a terminal,and input adb logcat,then you can see the log.
have a try :)
If you want to see it exclusively within vim then :!adb logcat will display the logs.
Use this in vim:
:!ant debug install && adb shell am start -n your.package.name/.YourActivityName
That will fire up the app in your device. For logging I just want to complement that if you log in your app use a tag and filter the log by a tag like so: adb logcat -s "tagname"
I am using Eclipse to debug an Android application on a device. I would like to keep the application data between debug sessions. I should be able to do this from the command line with something like this:
adb uninstall -k com.package.myprogram
adb install -r MyProgram.apk
But then, I have to debug on the command-line -- Eclipse is much nicer! Is there anyway to set these options for when I am debugging with Eclipse?? Or somehow set these options through an ADB shell, but then still use Eclipse for catching Breakpoints?
Eclipse does not do any black magic! for all matters ends up accessing adb.exe to talk to the device. by just typing adb on your command line, you will get host of options with which you can do a lot of things. Apart from adb, there are other tools too which can help debug. Research a bit on which suits you best.
Just create a launch configuration for your Android project in Eclipse (in the Run menu). If you modify your application code and run the launch configuration again, Eclipse will install the new version of your application on the device without touching any of its data. There is absolutely no need to uninstall the old version first.
When I want to test an android application, I create a new AVD, start it in the emulator, wait for the emulator to finish booting, and then use ADB to install the application, and when I'm done delete the AVD. Are there any tools that automate all of those steps? I tried writing my own but I couldn't find a way to tell if the emulator was completely booted, as the Android SDK website says not to use "adb wait-for-device install file.apk".
You're right not to use wait-for-device. It does not wait for the package manager to be available, which is what you need. I'm not sure how eclipse does it but you can poll the emulator until the package manager is available using the command adb shell pm path android. The command should return 'package: something'. Check out this python script that uses the technique: www.netmite.com/android/mydroid/1.6/.../adb_interface.py. It's pretty big but if you search for the command above you'll find the relevant piece of the script.
Why do you want to delete the AVD every time?
If you are deleting it every time because the install command throws an error due to the app already existing on the AVD, you can do this: adb install -r file.apk. The -r part is used for reinstalling the app. Here is the full usage instructions for adb.
Are you deleting it to remove the application you are testing and revert to a 'clean' emulator? If so it's not necessary to delete the AVD every time. You can specify the -wipe-data option when starting the emulator. This effectively resets the AVD to how it was when you created it. Here is the emulator documentation.
Hopefully that helps simplify your script.