7

If nothing is changed since last compile and run, and then I hit run again (green start button), it complies and then run.

How can I make it run directly without compiling the same thing?

JJ Liu
  • 1,351
  • 8
  • 20
  • 36
  • as far as i understand it, android studio uses a incremental compiler. That means only when a file changes does it compile. but, if you did Build | Rebuild Project, your entire project is totally recompiled. Let me fool around with the IDE a moment. – j2emanue Jun 01 '15 at 23:14
  • is your problem the *time* it takes for every run? if so then check the *Offline work* under *AndroidStudio->Preferences->Build, Execution, Deployment->Build Tools->Gradle-Global Gradle Settings*, it can build working offline except for some changes like *dependencies* modified... – Pararth Jun 04 '15 at 12:10
  • I thought this was a common behavior on any AS instalation. When I hit run again and haven't changed any files or dependencies, it shows me the following message on the Run menu: `No apk changes detected. Skipping file upload, force stopping package instead.`. – Thyen Hong Guedes Chang Jun 08 '15 at 21:35
  • Although this is not the answer, it might help you a little bit to make the compiling task faster (haven't tried myself) http://stackoverflow.com/questions/16775197/building-and-running-app-via-gradle-and-android-studio-is-slower-than-via-eclips – Eric Martinez Jun 08 '15 at 22:14

2 Answers2

0

I might be wrong, I don't think but it's possible when you pass by Android Studio, but by using the build apk and install it with Android Debug Bridge (ADB), you should get the desired behaviour.

When the project compiles, AS creates an output apk. Usually, this should be named app-debug.apk and located in build/outputs/apk/ folder:

Your .apk file (signed with either a release or debug key) is in your module build/ directory after you build your application.
cf. Running on emulator

By using adb, you'll be able to install this apk previously generated (and I believe, without compiling again) on the device with the command install:

$ adb install -r path/to/app-debug.apk

Once installed, you should retrive the command to launch your application. A little research bring me to "How to start an Android application from the command line?":

$ adb shell
$ adb am start -n my.package.name/my.package.name.MyActivity   

And then, you could combined them on same line to launch the apk just right after its installation. This looks like:

$ adb install -r path/to/app-debug.apk && adb shell am start -n my.package.name/my.package.name.MyActivity

Therefore, you application will run without compiling.

Community
  • 1
  • 1
Blo
  • 11,903
  • 5
  • 45
  • 99
-1

First try right click on the project and then select Run As Android Application. This will change you app default run configuration.

If this does't work then try to change it's run configuration from right click on project in project explorer and select Run as -> Run configurations.

Always run your project if you have opened that projects java class tab in workplace. You cannot run your project directly by clicking Green play button if you opened a XML file of that project. However you can run a project if you have opened manifesto of that project.

Sam
  • 75
  • 8