How to test deep linking on Android? - adb

I am trying to test Deep linking(locally) on Android. I was able to test on iOS with this link:
xcrun simctl openurl booted exp://127.0.0.1:19000/–/challenges/[SHARE-TOKEN]
For Android I tried:
adb shell am start -W -a android.intent.action.VIEW -d “exp://192.168.100.7:19000/–/challenges/[SHARE-TOKEN]” com.myapp.android
But I get this message: Error: Activity not started, unable to resolve Intent.
(ref: https://reactnavigation.org/docs/en/deep-linking.html#test-deep-linking-on-ios)
Is there any way I can test deep linking on Android or am I missing something?

You can simply use this:
adb shell "am start 'exp://192.168.100.7:19000/–/challenges/[SHARE-TOKEN]'"

Related

syntax error when running iperf through adb

I am trying to execute iperf through adb shell, however I am getting following error:
syntax error: unexpected 'newline'
here are the steps:
push android compiled iperf binary to /data/local/tmp
enter adb shell, go to /data/local/tmp folder.
chmod +x ./iperf2.0.10
./iperf2.0.10
I tried executing command from outside like: adb shell "command"
I tried few other phones.
I tried few iperf versions.
host machine: tried both mac and windows. on windows version info:
Android Debug Bridge version 1.0.41
Version 31.0.3-7562133
phone info: adb shell getprop ro.product.cpu.abilist
arm64-v8a,armeabi-v7a,armeabi
I made sure to pick relevant iperf binary form: https://github.com/KnightWhoSayNi/android-iperf
This is a galaxy S7 SM-G930U, android version 8.0.0, kernel version 3.18.71-14970140
I looked at the iperf source code and could not find any place which would print this error message, so seems like some issue with how adb is treating my command.
Please suggest what can I do now ?
Edit: updated some details

How to solve this adb server version doesn't match this client error in android?

adb server version (39) doesn't match this client (40); killing...
could not read ok from ADB Server
* failed to start daemon
error: cannot connect to daemon
adb: error: failed to get feature set: protocol fault (couldn't read status): Connection reset by peer
* daemon not running; starting now at tcp:5037
* daemon started successfully
- waiting for device -
error: protocol fault (couldn't read status): Connection reset by peer
I have the same issue when running adb devices command.
adb devices
List of devices attached
adb server version (36) doesn't match this client (40); killing...
* daemon started successfully
2322dc3d device
I ran command which adbwhich gave me the location of the adb that the previous command was using, in my case output was:
which adb
/usr/bin/adb
Then i ran whereis adb command which gave me the location of adb's:
whereis adb
adb: /usr/bin/adb /home/arefin/Android/Sdk/platform-tools/adb
/usr/share/man/man1/adb.1.gz
I get rid of this problem by moving the adb from /usr/bin directory with mv command: (meaning this is of no use thus instead of deleting just put in desktop),
/usr/bin$ `sudo mv adb /home/arefin/Desktop/`
After this i executed this command adb kill-server then ran adb devices. I found everything is fine this time.
My Android development related path in in $HOME/.profile file is, as below:
export ANDROID_HOME=/home/arefin/Android/Sdk
export PATH=$PATH:$ANDROID_HOME/platform-tools
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$JAVA_HOME/bin
When encountered this error in Linux,I deleted the adb file in my
/usr/bin/
and replaced with one which located in path (usually in home path)
~/Android/Sdk/platform-tools/
and it worked.
As pointed out in previous answers, this is due to having multiple adb versions installed in your system. Probably one from the android-sdk-platform-tools installed via apt and other from Android Sdk itself (which is usually newer version).
The simplest way to solve this in Ubuntu (or Ubuntu-based OS's) is to add this line at the end of ~/.bashrc file:
alias adb='~/Android/Sdk/platform-tools/adb'
#Change path according to your Android Sdk installation directory
And then reopen terminal for changes to reflect.
This avoids the need to mess with system files as well.
Probably you have two versions of adb in two different locations in your system. The running server version is 39 and the adb client version is 40. You can resolve this by keeping only one adb in your PC.
You can figure it out as shown below-
In Linux below command gives you adb location if adb binary is added to path.
which adb
if adb is not added to path and still you are getting this error then search for adb using below command.
locate adb
if your adb client is other than above location, you may add newest version to above path and delete the old adb version.
If you are using windows, you figure it out the two adb locations and keep only at single place.
I know this is a little old, but if you have this problem and you have Vysor installed, then you can resolve it by looking in the Vysor application folder for the adb.exe (and Adb*.dll files) and replacing them from your Android SDK folder. I'm on a Windows machine and the relevant paths for me were:
Vysor
C:\Users\\AppData\Roaming\Vysor\crx\gidgenkbbabolejbgbpnhbimgjbffefm\app-2.1.7.crx-unpacked\native\win32*
(I'm guessing the path will vary according to the version, etc, but this will hopefully help figure it out.)
APK
C:\Users\\AppData\Local\Android\Sdk\platform-tools
On my machine, the relevant files were:
adb.exe,
AdbWinApi.dll,
AdbWinUsbApi.dll
After this, you will need to kill the existing ADB task as described in the other answers to this post.
Solved by
Open terminal in Android studio
adb kill-server
sudo cp ~/Android/Sdk/platform-tools/adb /usr/bin/adb
sudo chmod +x /usr/bin/adb
adb start-server
Run
tasklist | findstr adb
then kill the duplicate process
TASKKILL /PID "PID_NUMBER" /f
Encountered this problem myself, none of the solutions online worked for me.
did this by chance and it solved my problem!
I'm using Android Studio on a Macbook Pro.
first I tried to install adb from brew:
brew cask install android-platform-tools
then I uninstalled it:
brew cask uninstall android-platform-tools
After the last line adb didn't work in terminal but did work in Android Studio immediately! =D
posted so it may help someone else - good luck!
For ubuntu (more precise - kubuntu) i had the similar problem.
The problem was in android-studio, to fix it you need to do these steps:
Go to SDK-Manager
In SDK-Manager click the SDK Tools menu.
Uncheck "Android SDK Command-line Tools (latest)"
I had the same issue connecting to my SFTP Server app and could solve it as follows:
The error was caused (in my case, Ubuntu 18.04.5 LTS) by conflicting adb installations. One Installation coming with AndroidStudio (IntelliJ) located in .../Sdk/platform-tools and one coming with the package manager installation apt install located in the standard directory for executables /usr/bin. The installation location for AndroidStudio (IntelliJ) can be found in the AndroidStudio (IntelliJ) Menu: Tools → Android → SDK Manager: Android SDK Location. And the installation location related to the package manager can be found invoking the command which adb.
And the solution to this problem is to uninstall one of them.
Depending on your use case, if you’re most of the time working with AndroidStudio (IntelliJ) (and this version is up to date), then remove the (outdated) version installed with the package manager as follows.
To uninstall first find out which packages relates to /usr/bin/adb with the following command: dpkg -S /usr/bin/adb.
And then call apt autoremove adb to uninstall the adb package and all its dependencies.
And last but not least in order to still being able to call adb from the command line update the PATH variable in “/etc/profile”, if it should be accessible for all users, or ~/.bash_profile or ~/.profile (whichever exists) if it should only be accessible for the current user and append the path “.../Sdk/platform-tools” (that you looked up above) at the end. And then reboot or log-out & log-in for the new path to get applied.
In ubuntu
delete the adb
-> usr/bin
-> (delete command) sudo rm -rf /usr/bin/adb
Android/Sdk/platform-tools/adb
-> copy this folderpath.
paste into
->usr/bin
->(paste command) sudo ln -s /home/yourfile/Android/Sdk/platform-tools/adb /usr/bin
restarting your system, would also work for you.
I have faced the following error and what worked in my case was just to restart the system.
could not read ok from ADB Server
* failed to start daemon
error: cannot connect to daemon code here
adb.exe: failed to check server version: cannot connect to daemon
I had a similar error. Two different adb versions were conflicting with each other which caused it to keep restarting.
Run this command in terminal => where adb.exe
This will show you where the different adb files are. You can look at the file property date to see which is the latest one. Then copy the latest one and use it to overwrite/replace the older one(s). This will make both adb versions be the same and prevent a conflict.
This generally happens when there are two adb paths are available. Uninstall one will help
--> npm uninstall adb
This worked in my case.
None of the other solutions worked for me - Windows/WSL2-Ubuntu
The error is misleading but for me it was cos the adb port 5037 was in use.
Solution: find and kill the process using port 5037
Windows: netstat -aon | findstr 5037 and Stop-Process -Id <id-from-netstat>
WSL will attempt to connect to Windows port 5037
In my case wsl Ubuntu has different adb --version than Windows, I don't have to keep my Android Studio latest(since this might not your choice and do not guarantee same version as apt) or try with $PATH(wsl run Windows exe is not make sense).
The solution is simple, I download both Linux and Windows SDK Platform-Tools from official site which guarantee same version, then invoke relevant adb on each platform.
In my case I'd installed "AirDroid" on my windows machine and it runs "AirDroid_adb.exe", I had to kill that to get things to work. I have reported that they are using an old version of adb and they will hopefully fix it.
A Working Simple Answer for Windows:
make sure you have the sideload file (whatever.bin) in a sub directory of your adb executable.
make sure your adb executable folder, and sub directories are in PATH (look up DOS commands for PATH in Windows)
open a command prompt in the same directory as the sideload file
enter your command for example:
adb sideload mynewrom-5.4.3.2.1.bin
(Your device needs to be in recovery - sideload state before you send)

Android Things: take a screenshot

How do you take a screenshot via ADB for Android Things? I have tried:
adb shell screencap -p /sdcard/screen.png
adb pull /sdcard/screen.png
adb shell rm /sdcard/screen.png
and
adb shell screencap -p | perl -pe 's/\x0D\x0A/\x0A/g' > screen.png
I couldn't make screepcap work in Android Things Developer Preview. The command results in a 0-size file.
That said, I recommend the following two options: either use the framebuffer or record a video (screenrecord seems to work) and convert it to an image later on by proper tool. I'll consider the first option, so the steps would be:
Pull the framebuffer to the host machine. Note that you need to start adbd as root in order to pass a permission check:
adb root
adb pull /dev/graphics/fb0 screenshot
Convert the raw binary to image by the tool you prefer. I'm using ffmpeg. The command below might not work for you due to different screen resolution or pixel format. If so, make proper changes.
ffmpeg -f rawvideo -pix_fmt rgb565 -s 800x480 -i screenshot screenshot.png
Seems, because of old limited OpenGL version in Android Things, described by Tatsuhiko Arai here there is no possibility to get screenshot via ADB, but You can record video (e.g. from Android Studio, or via ADB commands) and than grab frame from it, for example via ffmpeg:
ffmpeg -i device-2017-01-23-193539.mp4 -r 1 screen-%04d.png
where device-2017-01-23-193539.mp4 - name of recorded (via Android Studio) file .
I've tried exactly this code with a little bit change like below (but no matter) and it works well. The image is in my platform-tools directory now.
adb shell screencap -p /sdcard/screen.png
adb pull /sdcard/screen.png screen.png
adb shell rm /sdcard/screen.png

Cannot pull APK from Android device with adb

I'm trying to get the APK of an installed application from my device. I'm following the instructions in this answer but when pulling it, adb says the APK doesn't exist. This are the exact steps:
$ adb shell pm list packages
...
(whole list of packages)
...
$ adb shell pm path com.google.android.apps.books
package:/data/app/com.google.android.apps.books-1/base.apk
$ adb pull /data/app/com.google.android.apps.books-1/base.apk
adb: error: remote object '/data/app/com.google.android.apps.books-1/base.apk' does not exist
How can I pull this file to my local drive?
Try this:
$ adb shell cp /data/app/com.google.android.apps.books-1/base.apk /storage/emulated/0/Download/base.apk
then
$ adb pull /storage/emulated/0/Download/base.apk

adb install [app_name] - Failure [INSTALL_FAILED_ALREADY_EXISTS]

Firstly I'm aware that this has been asked many many times, but I've tried all those answers and still no luck. Let me explain.
I have 2 apps, 1 stock app, and one with the fino tool added in (sysdream/fino). This all repackaged correctly and was resigned correctly however when I try:
adb install app_fino.apk
Failure [INSTALL_FAILED_ALREADY_EXISTS]
And adb install -r, which is obvious as I added fino to it and resigned.
adb install -r app_fino.apk
Failure [INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES]
Other answers said to Uninstall and then reinstall the new app. So headed over to Apps > All > Uninstalled
...Rebooted phone
adb install app_fino.apk
Failure [INSTALL_FAILED_ALREADY_EXISTS]
Any ideas anyone?
Try this command to uninstall:
adb uninstall com.your.packagename
If you still get the INSTALL_FAILED_ALREADY_EXISTS message even after an
adb uninstall com.your.packagename
The application may still be present on the system partition and thus cannot be removed using adb uninstall.
To fix this you need to also remove the original system app (can only be done on a rooted device):
adb shell
$ su
# mount -o remount,rw /system
# cd /system/data
# rm OffendingPackage.apk
Note that the package names in the system folder not necessarily follow the com.your.packagename.apk convention. So you may need to look around a bit for the correct apk.
Finally adb reboot the device before trying to install again.

Resources