6

Today, I update my Android Studio(4.1.1)

When I changes in my code and click on "Run App" then dialog shows Do you want to terminate the process 'app' and there are 3 options Terminate, Disconnect, Cancel. Can you tell me what are difference in these because if click anyone then app restart.

Which option is best?

Dialog Picture: Do you want to terminate the process 'app'

Robert
  • 39,162
  • 17
  • 99
  • 152
TexD
  • 162
  • 1
  • 10

3 Answers3

6

There is best option. What you have to select depends on what you want to achieve.

This dialog only makes sense if you have already started the app before. If you now run again the app Android Studio want's to know what to do with the existing running app as an there can be only one running instance of an app at a time.

Terminate

This will directly exit the app without saving and data or anything else. The app process will just be terminated.

Disconnect

Close the connection between the debugger in Android Studio and the app as the debuggee. Afterwards the app will continue to run just without attached debugger.

Cancel

Do nothing and just close the dialog

Robert
  • 39,162
  • 17
  • 99
  • 152
  • Thanks, now I understand. But if we click on Cancel then running app also restart with changes code. – TexD Nov 14 '20 at 09:29
  • @TexD Then Cancel seems to trigger ["Instant Run"](https://stackoverflow.com/questions/42523441/what-is-android-studio-instant-run) hot/warm code replacement. I am not sure if this always happens. – Robert Nov 14 '20 at 11:49
  • `Close the connection between the debugger in Android Studio` With the debugger did you mean [the Android Debugger](https://developer.android.com/studio/debug)? The debugger which starts when you click on `Run>Debug app or Attack Debugger to the Android Process`. I am asking because the Android Debugger is often not attached and this dialog shows up every time a running app is run again. If there can be one process and disconnect disconnects the process then again don't you end up with two process? cc @Robert – Sudhir Singh Khanger Nov 23 '20 at 09:25
  • @SudhirKhanger Even if you don't debug the app and hence assume that no debugger is connected the debugger may be connected to perform hot code replacement. – Robert Nov 23 '20 at 09:30
  • @Robert in that case disconnect will disconnect and terminate will both terminate and disconnect and cancel does the hot reload or apply changes. Is disconnect useful in cases when you are testing something related to long running task where you may not want to kill the process and still be able to change the code. I suppose terminate would also be useful in similar case. It seems best option in case you are not testing anything related to threads then Apply Code Changes would be the best possible option. But the question is that would really change the code and bring expected results. – Sudhir Singh Khanger Nov 23 '20 at 11:19
2

Command , (Setting or Preference) Version Controll > Confirmation > "when files are created" add or delete option check!!

chakangost
  • 46
  • 2
1

I was having the same problem. Here is the simple solution that worked for me. Check Remember, don't ask again then press Disconnects. Lastly close your emulator and run the app again.

l-l
  • 3,804
  • 6
  • 36
  • 42
Majura1
  • 11
  • 2