1

In Eclipse, with my phone hooked up via USB, I have everything configured so that when I run the project the application deploys to the phone and runs.

Is it possible to do this without opening up eclipse, just from the command-line?

(I want to be able to walk from the kitchen to the computer, make a quick change with a text editor and deploy, before my wife gets a chance to asks me if I'm "on the stupid computer again.")

LimaNightHawk
  • 6,613
  • 3
  • 41
  • 60

2 Answers2

1

SUre, in a few commands. You can turn it into a shell script.

First, run ant from the main directory.

When done, run adb install bin/apk_filename_here

THat will install it.

Edit, thanks to camdroid:

To run it automatically, use adb shell am start -n com.package.name/com.package.name.ActivityName

Gabe Sechan
  • 90,003
  • 9
  • 87
  • 127
  • You actually can run it from adb - check out the answer to this question: http://stackoverflow.com/questions/4567904/how-to-start-an-application-using-android-adb-tools. – camdroid Jun 16 '14 at 17:46
1

You can use export a Gradle for Android build file and use Gradle to build your application at the command line. Or, you can use android update project to create an Ant build file, though Ant support is starting to fade away for mainstream Android development.

Both of those would allow you to build and install the app from the command line. You can also use both to run your instrumentation test suite from the command line. And, with some custom tweaking of your build files, you could even get them to run the adb shell am command to run your app, rather than you having to manually tap on something in your emulator or device.

However:

  • Both Gradle and Ant are outside of Eclipse. Depending on the changes you make to your Eclipse project (e.g., adding JARs or library projects, changing build targets), you may need to adjust the build scripts to match.

  • Eclipse will be oblivious to the file changes you make outside of Eclipse, forcing you to use F5 or the equivalent to get it to load your changes.

  • You may wish to seek marriage counselling, to determine if all of this is worth the risk. Note, however, that this is outside the scope of Stack Overflow.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491