Android: How to stop emulation - android

I'm coming from Visual studio and C# and am new to Android (and eclipse) so quite ignorant of basic functionality.
I've written a short app and ran it under the emulator. No problems.
Now I've made some changes and want to test them. In VS I'd stop the application debug run before making code changes, and after the code changes run again.
I can't find the 'stop' debug button in eclipse. How do I run my app after I've made changes?

What you can do is press the [Escape] key on your keyboard or the 'Back' button within the Emulator to close your app then rebuild and run it in Eclipse, which should bring it up as active in the Emulator.

You can just run it again and the code changes will apply.
But else you'll find it under the Debug-window (Window->Show View->Debug) and there is a "terminate" button in the top right corner of your screen.
You might need to close the app inside the emulator though..

There is deference between just running the application and debugging, you can pres play in ellipse and that will run the app but what you can also do is to switch the perspective in debug view (to switch go to the right top corner, and change from java to debug perspective)
in debug mode you can also set break points, just like in visual studio the only difference here is you must change perspective

Related

Expo's Android app not responding properly to code changes and shaking

I've started developing a react-native app using Expo and running it in my Android phone. Things worked OK at first but then suddenly:
Every time I introduced a syntax error on my code, my phone would not display the compiling errors (they used to appear as white text on a red background) but instead it would show an uninformative error screen with a blue background.
My phone stopped responding to the shake gesture in order to access the dev menu. (I wonder who thought that shaking was a good idea as opposed to a more conventional menu...)
Live recompiling stopped working.
Even when refreshing manually, changes to my code sometimes won't be applied. It looks like the expo app is working with an old, cached version of my code.
Expo is indeed running in production mode. Any pointers?
Since you mentioned your project is running in production mode you must change it to development mode, you can do this by clicking the toggle button on expo-cli's interface.
Alternatively if you're using Expo CLI just press p while your project is running to toggle between modes.
You can read more about Dev/production modes here.

Android Studio 2.1.1 running old .apk file

Start of with, I tried all the suggestions in SO and none helped me.
Suggestion1,Suggestion2,Suggestion3.
I'm doing some debugging (Just running the app on my device through Android Studio) and I noticed that time after time, changes that I made in the app does not applied to the .apk AS is running.
The only solution I know is to delete the app from my device and then running again and it compiles with the changes I made in the code. Alternatively, I restart Android Studio and it fixes that too.
I try all suggestions on the site including: file -> invalidate Chaches / Restart -> invalidate, and changing my Run -> Edit Configuration settings but turned out unsuccesfully.I also read all the documentation here but It just repeats the answers here.
My Run -> Edit Configuration
So what's up with Android Studio not applying my code changes?
EDIT:
So for now still no fix suggestion is working. Even my File -> Invalidate Caches / Restart -> Invalidate and Restart not working either.
There is a bug with the new Instant Run feature, the app is not reloaded correctly.
You can disable Instant Run in File > Settings > Build, Execution, Deployment > Instant Run and uncheck the first checkbox. Now when you click the Run button, the app will be refreshed correctly.
How do you deploy the changes in your app to the device? I used to do it by pressing the green triangle (the "play" button) which is the first on the right from the name of the app in the top toolbar. In the new AS version, when you make changes to your app, that button gets a small thunderbolt icon next to the green triangle, like here:
This new icon means that AS will try to do an "Instant Run", ie. to make a hot swap or a warm swap to your app as it is running. Sadly, this hasn't been working as advertised for me (I have been using the new AS for a week now). Instead, I go for the "ReRun selected configuration" button, the fifth on the right, with the gray square and the curved arrow in order to send the changed .apk to the device.

Enable debugging without relaunching app in Android Studio

This is, by far, the most missed feature for me.
When using eclipse, in the devices view I was able to enable debug for specific app without relaunching.
I can't find such a feature in Android Studio. Relaunching the app all over in the debug mode is real pain. Is there a way to enable it in the middle of the process like it is possible in eclipse?
There is an icon for that on the main toolbar which is called Attach debugger to Android process (highlighted in red in the image below):
The same option can also be found on the Run menu.
Once you click this, a list of processes from attached devices will be displayed. Simply choose the one you want to debug and you're set :)

Debugging in Eclipse/Emulator not hitting breakpoints

I have configured a VD through Eclipse and it starts up fine. If I press F11 from one of my .java files in my application project, it starts up a new instance of the emulator and installs the app on it. However it does not open the app and if I manually open it and click on action buttons, it plainly is not linked up to the IDE for debugging as no break points get hit.
Other times when the emulator is open, F11 does the job of re-installing the app (after I manually uninstall it from the emulator), but again it does not attach as a debugger, just installs the app so I can run it.
Is there something basic I am doing wrong so that step-through debugging is not working?
Eclipse having option Skip All Breakpoints,
it might be possible you enable this option so you need to disable Skip All Breakpoints,
Option will appear when you will right click on project and trying to run it.
You can also do it by UI of eclipse , figure out this images. there are a option, if you toggle this button option it will behave disabe/ enable

How to configure which project to debug?

I want to run two different Android apps from Eclipse (in two different types of Emulators) simultaneously but step through one of them, in which I've set breakpoints.
How do I configure which of the two apps is the one being debugged? It's not possible to debug both simultaneously, is it (with breakpoints in each project)?
If you take a look at this image, you can see that the "Devices" tab in the DDMS perspective has a "Bug" icon (the first one). If you highlight your running app (in whichever emulator it is) and click that button, debugging will become enabled for that app. If you have any breakpoints set in your code it will hit them and the debug view will open. That's the easiest way to debug a running application. I find this is the best approach because running the whole app in debug mode is slow. It's better to start debugging once you are close to where you actually want to step through.
You can also do this on an actual device, but you will need to set the debuggable="true" flag in the manifest, otherwise your app won't show in the list.

Categories

Resources