adb -s <device_id> shell pm clear <package_name> - deletes the app from the emulator - android-emulator

I am trying to clear app's data from several emulators, in a loop inside a bash script.
Doing so from the terminal indeed clears the app's data, but doing so from a bash script will also uninstall the app from the emulator and close the emulator's window (UI).
I don't want my app to be uninstalled as i need to test it.
Is there a reason that this command works differently when executed from terminal vs. when executed from bash script? When executing from a script against a real device it works perfectly as it should - clear the app's data without uninstalling the application from the device.

I found the answer.
When the emulator is open (with GUI) - the command will work as it should, that is clear the app's data.
When the emulator is open without GUI - the application will also get uninstalled.

Related

Why terminal becomes unresponsive after Parcel build?

I am following Parcel's "Building a web app with Parcel" to learn how to use it. The problem arises after I type in npx parcel src/index.html. The build runs fine and I can see the development server results just fine. The terminal becomes unresponsive afterwards. I can't type, quit, or anything. The only workaround is killing the terminal and restarting...which is very annoying. I've looked for answers, I've updated Node to the latest version, but to no avail. This doesn't happen when I use Webpack or any other time. Here is a screen shot just in case that helps. Could someone please help this unworthy noob out? Screen shot of terminal and VSCode
When you just run npx parcel, it starts a development server that will continue to run until you exit. This development server will watch for changes that you make as you develop and will reload your project, so you don't need to restart/rebuild every time you make changes.
The reason you can't type anything into the terminal (or, at least, that the terminal doesn't respond when you do) is that the development server is still running in that terminal. You have to exit the development server before the terminal prompt will re-appear and you can use it as normal.
To exit any program running in a terminal, you can type Control+C (hold down the Control key and hit the "c" key). This works for any terminal program, not just parcel. This will exit the development server program and you'll get your terminal prompt back.
There are other things you can do with programs (or "jobs") in the terminal window. You can read more about them here and here.
But you should use the development server to your advantage. Keep it running while you work. If you need to use the terminal while it's running, just open up another terminal window.
When you finally want to build your app/site, run parcel build instead.
You can read more about all of this here: https://parceljs.org/getting-started/webapp/

VS Code Integrated terminal does not execute commands from extensions

Ideally, the integrated VS Code terminal, depending on the context, the type of the folder and the extension, executes some commands. For example, when opening a folder containing a Python virtual environment in VS code, the environment is recognized and activated (by the python extension) by default when opening a new integrated terminal instance (situation 1). This is done by running some command similar to source /path/to/venv/bin/activate.
Or, when using the ROS extension to debug nodes, selecting "Start Debugging (F5)" uses the launch.json file to start some nodes and finally starts debugging the desired code. To do so also, there is some command that is executed (also by he ROS extension, I assume) in the integrated terminal (situation 2) to start the debugging process. In case of debugging ROS nodes, the command usually looks something like /usr/bin/env /bin/sh /tmp/someFileName.
But, unfortunately, both of the above mentioned situations fail. I believe this happens because while the extension tries to run these two commands within their respective integrated terminals, the commands do not actually get executed in either situation. Instead, these commands are printed on the top of the terminal, but the state of the terminal is unchanged (as opposed to when the commands would have been executed, in which case depending on the commands some actions are performed). Here are two images to show what I mean. Top, situation 1 and bottom, situation 2.
The fact that these two commands are printed on top of the terminal as soon as the a new terminal instance is opened tells me that the extension tries to execute them, but they do not work for some unknown reasons.
Just to be clear, both of them are run in a seperate VC Code window, they have nothing to do with each other. When I manually run both the commands in their respective terminals I do get the desired results.
Now, I am unsure exactly how to name this issue. But I think this is surely an issue with the integrated terminal, and not a problem of the extensions. I am not sure how one could reproduce this problem.
I did a clean reinstall of VS code by deleting %APPDATA%\Code and %USERPROFILE%\.vscode. Because I am using this on WSL, there is only ~/.vscode-server on the ubuntu side. I manually uninstalled all extensions on WSL but did not delete this folder, in fear of breaking something. The problem still persisted. I have also created an issue on the VS Code GitHub page with nearly the same information.
I am unsure if this is a bug or is there something wrong with my settings. Does anyone know how I could fix this? For smaller use-cases I can still manually enter the command in the terminal. But I am trying to debug a ROS application with nearly 10 different terminals opening up and I cannot be manually entering the command each time to restart the process.
Please let me know if you need any more information. Many thanks in advance.
Edit: both edits to frame the question properly.
Although not related to WSL, I dug a little deeper today as to why in my case the extension commands were not being executed or were being chopped.
I'm an iTerm2 user. iTerm2 has something called Shell Integrations, which allow iTerm to behave differently under certain circumstances, for example, adding markers to each prompt or coloring output with certain text (e.g. WARNING or ERROR)
From time to time, I also use the VSCode Integrated Terminal, which recently added support for reporting whether the previous command errored out with an indicator on the gutter of the Integrated Terminal panel using the exit code.
iTerm can do something similar but the shell integrations mess up completely the VSCode functionality and therefore I changed my .bashrc file to detect if the terminal emulator was iTerm2 or not (which can be done with the it2check utility of iTerm2) so that it only sourced the shell integrations if I was using iTerm2.
The problem is that it2check "eats" some STDIN bytes using dd, specifically, until it finds an n so that it can obtain the name of the emulator. This of course chops the commands on the STDIN until the first n and makes VSCode Extension Terminal commands unusable
The workaround I came up with is to use the value of "$TERM_PROGRAM" as means to distinguish between the different programs. The only caveat is that the value won't be passed if you're inside of a tmux session or similar, but I can live with that.
In your case, I'd check for any process that is either not passing the STDIN to the WSL process or any dot files or shell profile scripts eating up the STDIN they receive.
I suspect that the real problem is that the local process doesn't relay the STDIN contents to the WSL and as a workaround you may try to create a VSCode Integrated Terminal profile that uses SSH to connect to the WSL host so that the STDIN is preserved

How to send argument from desktop shortcut to a shell invoked UWP app that uses AUMID

I have a win32 store app (desktop-bridge) converted and it works fine.
I want to create a desktop shortcut for this Store App that
uses AUMID to start the app (solved below)
and also passes an argument to it (not solved)
Here are the things I have tried:
I know how to start the app from command line using its AUMID.
explorer shell:appsfolder\[aumid]
I see that I can even use this as a target in a desktop shortcut and it works.
Now, I also want to pass arguments to the app which I can't do with the explorer command above.
But if I use start, it works:
start shell:appsfolder\[aumid] "an-argument"
But I can not put the above start command as target in a desktop shortcut. So how do I create a desktop shortcut that is able to start the store app above with an argument?
Another way to look at this question is, how to create a desktop shortcut with the start command?
Update: Got an answer from another question and the following works in the shortcut except that there is a blink when the command line window comes and goes.
cmd /c start shell:appsfolder\[aumid] "an-argument"

Angular ng serve asking to open app and not working

Problem Statement
When I try to do ng s -o in my terminal for my Angular app, it says, "How would you like to open this?" inside a popup box where I can choose an app, but choosing an app doesn't work.
Image of Problem
When I try to choose an app, it displays code. When I chose Chrome in the popup box, this happens:
The image shows that when I run an app after ng s -o it just displays code. Also, the tab title in the browser says "ng" when the code shows. Another thing, there is no error in the terminal...
Expected Results
I want to run my Angular app with ng s -o.
Actual Results
The app doesn't serve and asks to open an app.
Note: I am using Visual Studio Code for this.
The problem was related to my cli. I was using PowerShell when I was running ng, and for some strange reason, PowerShell stopped running ng and was asking me to open an app to run the file. Even though this never happened to me before and I was using ng and PowerShell just fine before. Strange!
Now I am using CMD instead. It now runs perfectly. So, I switched cli's from PowerShell to CMD in my integrated terminal in Visual Studio Code and it started working.
I got the idea to switch cli's from this: https://github.com/Microsoft/vscode/issues/28541
npx ng serve -o works for me in visual studio code.
The problem was caused as the Vs code was using PowerShell mode. By changing it to default cmd mode, the ng commands started to work.
The steps to change from PowerShell to cmd mode is as follows:
Press Ctrl + Shift + P to show all commands.
Type profile in the displayed text box to filter the list.
Select Terminal: Select Default Profile.
You will be prompted to select your preferred terminal shell, you can change this later in your settings or follow the same process as we do now.

Chrome remote connection connects but then drops out

I am really struggling to get Google Chrome Remote Debugging to work! I have the phone setup and confirmed:
Then below are what I see in chrome://inspect/#devices and also F12 (both open at the same time);
It flashes with the "Connected" for about 3 seconds, and then goes to:
Offline
ZX1G324RSV Pending authentication: please accept debugging session on the device.
It's driving me nuts, as it should be simple to do, but it just doesn't want to play ball :/ Do I need to do anything special? I've used it before on this PC and although I had some fun and games with it the first time around, it worked after that.
There seems to be a ton of posts/articles about how to fix it, but none of them are working for me. https://bugs.chromium.org/p/chromium/issues/detail?id=450492 for example.
Download Android SDK here ("SDK Tools Only" section) and unzip the content.
Run SDK Manager.exe and install Android SDK platform tools
Open up the Command prompt (simply by pressing the windows button and type in cmd.exe)
Enter the path with ex: cd c:/downloads/sdk/platform-tools
Open ADB by typing in adb.exe
Run the following command by typing it and pressing enter: adb devices
Check if you get the prompt on your device, if you still can't see your phone in Inspect Devices run the following commands one by one (excluding the ") "adb kill-server" "adb start-server" "adb devices"
Here are the things that you can try:
Try different USB cable(s)
Try different USB ports on your machine(for some people using 2.0 port worked out)
Try the same process, with unchecked 'Discover USB Devices' in chrome://inspect (then Chrome will connect through the ADB server, not directly) ==> This solution worked in my scenario.