What is "adb.bash" used for? - android

in the script ./build/envsetup.sh
in the function addcompletions() it finally run the command . /sdk/bash_completion/adb.bash
What is this command here for?
And what is the script "adb.bash" used for?

The file sets up integration between the bash shell and adb. Specifically, it sets up command line completion, so you can type "adb " and press tab, and get a list of adb commands you can use. Briefly skimming it, it seems like it might also support remote file listing by pressing tab twice in contexts where that is appropriate (e.g. after 'adb pull').

Related

How to run "adb push" command before launching an activity from Android Studio

I have some test data for my program that i want to push to the device before a test activity is run or debug. On the command line this is:
adb -s RF8M40T69JX push --sync -z any test_data /storage/emulated/0/Download/test_data
I know i can run an external tool shell script with the "Before launch" configuration option. But this does not give me any way to know on which device Studio want to start it. I don't want to waste the time and dispatch to every possible device and every Edit-Compile-Run cycle.
I checked that the device signature is unfortunately not passed as environment variable to external tools as it should be. Is there any other way? Can i do this with some Gradle magic?

adb not working in powershell but adb.exe works

when typing "adb devices" in Powershell, it return a prompt to ask "How do you want to open this file".
However, if I use "adb.exe devices", it works and give me the list of devices.
As I have a lot of scripts written as adb instead of adb.exe, is there a way to fix this?
In cmd, typing adb devices would also work. But the scripts were all PS based. So fixing this in powershell will really helps. Thanks.
As you've confirmed, the problem was an extraneous, empty file literally named adb (without a filename extension) that resided in your C:\WINDOWS\system32 directory.
Since the PATH environment variable (typically) lists C:\WINDOWS\system32 before the directory in which the desired target executable (adb.exe) is located, C:\Program Files (x86)\Intel\Platform\..., PowerShell attempted to execute C:\WINDOWS\system32\adb, which - as an extension-less file - triggered the GUI dialog you saw.
Removing the extraneous C:\WINDOWS\system32\adb file solved your problem.
Get-Command -All adb helped discovered the problem: it listed all forms of a command named adb known to PowerShell, in order of precedence, with information about their type and location; that is, the effective command - the one that is actually invoked - was listed first.
Read on for background information.
As all shells do, if a command uses a mere (file) name (as opposed to a file path), PowerShell looks for executables in the directories listed in the PATH environment variable (accessible as $env:PATH in PowerShell), in order.
That is, if you submit a command line with command name adb, PowerShell - after looking for an internal command by that name first (an alias, function, or cmdlet) - looks for an executable file whose base name is adb, in the directories listed in $env:PATH, and invokes the first one it finds.
On Windows, an executable file is one whose filename extension is listed in the PATHEXT environment variable ($env:PATHEXT); again, the extensions listed there are considered in order. By contrast, on Unix-like platforms it is solely the file mode (the permission bits) that determine whether a file is executable.
However, unlike other shells, PowerShell doesn't just look for executable files in $env:PATH, it considers any file that exactly matches the command name given executable, and in effect passes such a file to the Invoke-Item cmdlet, which triggers the default GUI shell action on the file, equivalent to double-clicking a document in File Explorer on Windows.
This problematic behavior is discussed in this GitHub issue, which proposes that only true executables be considered commands.

How to run cloned (dual) apps via adb shell

Could someone tell how to run cloned (dual) application via adb shell. The smartphone has MIUI 11 and the app is TelegramX, for example. Application clone emulator is by default.
I get the original application when I try to run the app via:
adb shell
monkey -p org.thunderdog.challegram 1
The package list tells only this point:
package:org.thunderdog.challegram
And no hint to the cloned one.
Meanwhile, directory to the clone application is:
/data/user/999/org.thunderdog.challegram
instead of
/data/data/org.thunderdog.challegram that original has. Prpbably, it can be helpfull somehow.
I can't find anywhere documentation about how Dual apps are implemented and how to run such apps through adb.
Thanks in advance!
adb shell
Once you’re in an ADB shell, enter the following command:
settings get secure clone_app_list
If you are already using the App Twin feature, then you should see either one or two package names returned with this command. If you aren’t using this feature, this string will be empty. Now, we will either append to the existing list or create a new list of apps to clone.
settings put secure clone_app_list "PACKAGE#1;PACKAGE#2;PACKAGE#3"
Source: [1]: https://www.xda-developers.com/how-to-clone-any-application-with-emuis-app-twin-feature-no-root/

mac os - How to create and activate conda (a virtual environment) from a bash script?

How to create and activate conda (a virtual environment) from a bash script?
I've read a lot of stack overflow posts already None of them really make any sense to me, given that I'm a beginner with bash. Also, most of them pertain to virtualenv, and not conda, which adds to the confusion.
I don't really understand how source or exec works, or if I even need to use it for this purpose.
All I'm trying to do is create a conda virtual environment from inside a bash script, and then activate it. Then run more commands via the bash script on the newly activated "environment".
Instead, what is happening when I run the script below, is that the environment is created, but it's not activated. It's also not helpful that the terminal asks for a prompt to proceed with the creation of the virtual environment (human input required not good).
Here's the script:
#!/bin/bash
dirname=$1
conda create -n $1 python=2.7
source activate $1
Terminal shows:
Jills-MBP:Desktop jillr$ bash site_builder.sh blah
Fetching package metadata: ....
Solving package specifications: ..........
Package plan for installation in environment /Users/jillr/anaconda/envs/blah:
The following NEW packages will be INSTALLED:
openssl: 1.0.2l-0
pip: 9.0.1-py27_1
python: 2.7.13-0
readline: 6.2-2
setuptools: 27.2.0-py27_0
sqlite: 3.13.0-0
tk: 8.5.18-0
wheel: 0.29.0-py27_0
zlib: 1.2.8-3
Proceed ([y]/n)?
The solution was as stupid as calling the entire script with "source" instead of "bash". UHHHHHHHHGGGG!
Instead of
bash site_builder.sh blah
Use
source site_builder.sh blah
If someone actually explains why this solves it, that would be fantastical, because I still don't understand what "source" is doing.
https://superuser.com/questions/46139/what-does-source-do says, "source is a bash shell built-in command that executes the content of the file passed as argument, in the current shell."
As opposed to what other shell?
"source script reads and executes commands from filename in the current shell environment"
What other shell would they be executed in?
What shell is "bash site_builder.sh blah" opposed to "source site_builder.sh blah" ??

connect android device wirelessly through command line

This might be a dumb question, but I'm trying to connect a tablet so I can make an app in Android Studio. All the guides I see (https://developer.android.com/studio/command-line/adb.html#wireless) tells me to go to the command line and use adb commands. Where do I have to navigate to to use that command?
I've gone to C:/Users/myusername/AppData/Local/Android/sdk/tools
from there I've tried navigating to other directories and try to use the adb command but it won't let me. I don't know which directory I have to navigate to to use the adb commands, but I believe it's somewhere around where I'm looking, but I can't exactly find it.
C:\Users\username\AppData\Local\Android\sdk\platform-tools
from there right click and open command window here and then continue as described here: https://stackoverflow.com/a/3623727/3838663

Categories

Resources