I can't figure out this issue with android debug bridge (not working at all).
On a Windows 10 PC
platform-tools_r33.0.3-windows downloaded and unzipped folder "platform-tools" in C: (from https://dl.google.com/android/repository/platform-tools-latest-windows.zip)
Added system variable "Path" : "C:\platform-tools" in Environment variables
I run cmd as admin, then adb and get:
Android Debug Bridge version 1.0.41
Version 33.0.3-8952118
Installed as C:\platform-tools\adb.exe
[...all options...]
ISSUE:
any command for adb (e.g. "adb devices") results into:
"adb.exe: failed to check server version: protocol fault (status 00 1b ffffffd0 02?!)"
FAILED ATTEMPTS:
restart PC
kill-server / start-server
uninstall - reinstall adb
running adb from different directories (C:, C/platform-tools, other)
with an android device plugged in or not
removing C:\platform-tools from Path
adding C:\platform-tools to user Path (instead of system AND concurrently)
So this might be a bit of an edge case, but I'm using visual studio on a VM, and I have my phone in my hand. I'd like to set things up that when I press "play" in visual studio, it compiles my cordova app, and pushes it to my phone next to me, so I can test and debug etc.
My phone is 'rooted' and I have installed ADB wifi. I am able to connect to it from Visual Studio's adb version and also adb devices lists it.
(output from cmd.exe running as Admin in the solution folder)
C:\Stuff\Code\svn\myapp\MyApp>adb connect 10.10.10.6
already connected to 10.10.10.6:5555
C:\Stuff\Code\svn\myapp\MyApp>adb devices
List of devices attached
10.10.10.6:5555 device
When I press Play in Visual Studio it compiles and gets to the point where it needs to deploy to the phone and then it comes up with the following error: The system cannot find the file specified
(output from "output" tab in visual studio)
C:/Stuff/Code/svn/myapp/myApp/platforms/android/build/outputs /apk/android-debug.apk
No scripts found for hook "after_build".
No scripts found for hook "after_compile".
------ Copying back to project: android
2>------ Deploy started: Project: MyApp, Configuration: Debug Android ------
2> Querying ADB for attached devices...
2>The system cannot find the file specified
2>The system cannot find the file specified
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
========== Deploy: 0 succeeded, 1 failed, 0 skipped ==========
I had a similar issue and this worked for me...
adb kill-server
adb tcpip 5555
adb connect 10.10.10.6
adb devices - should show your device
Open Visual Studio as Admin
Type: ALT+B, R (ALT+B then R) to rebuild your solution
Run your app
I'm using appcelerator studio version 4.6.0.201605201934
I'm using a nexus 6P, and windows 10
The phone has debugging enabled, and has MTP mode selected. File-Explorer detects the phone each time it is plugged in and tries to download photos from it.
I have put the google USB folder in the android/sdk/extras/google/usb_driver folder
I can see my device on the command prompt by going to the android/sdk folder
adb devices -l
HOWEVER when i go to appcelerator studio, it does not find the phone - the "run configurations" has an empty list of phones to choose from, and running it leads to it informing me that there is no device connected.
What am I doing wrong?
Have you tried to run the kill-server, and devices commands with the adb path?
In my case:
bash-3.2$ /Applications/Android/android-sdk-macosx/platform-tools/adb kill-server
bash-3.2$ /Applications/Android/android-sdk-macosx/platform-tools/adb devices
List of devices attached
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
If this still doesn't solve your problem, try to add the Vendor ID of the device to the adb_usb.ini file, usually placed:
Windows: C:\Users\YourUser\.android
Mac OS: ~/.android
You can find the Vendor ID at the hardware info on Mac OS here: /Applications/Utilities/System Information
There is also a list of Vendor IDs at the android documentation: https://developer.android.com/studio/run/device.html
Your file will look, like this:
# ANDROID 3RD PARTY USB VENDOR ID LIST -- DO NOT EDIT.
# USE 'android update adb' TO GENERATE.
# 1 USB VENDOR ID PER LINE.
0x18d1
I have been using Titanium for some time and I also have the same issue regardless of what device or USB port I use. I even have the issue with simulators.
So I do the following instead:
# Install the application (replacing the existing one if it exists)
adb install -r build/android/bin/YOURAPP.apk
# Run the application (you could also just open the application on your phone)
adb shell am start -n com.package.name/com.package.name.ActivityName
# Show logs
adb logcat "TiAPI:*" "*:S"
The adb tool can be found in windows 10 at this path
/Users/username/AppData/Local/Android/sdk/platform-tools/adb.exe
The activity name can be found in the build/android/AndroidManifest.xml file.
It's usually: YourAppNameActivity
More information about logcat can be found here:
https://logmatic.io/blog/a-how-to-guide-to-debugging-with-android-logcat/
https://developer.android.com/studio/command-line/logcat.html
When trying to run
tns run android --device xxxx
I always get an err like this:
Error: error: could not install *smartsocket* listener: cannot bind to 127.0.0.1:5037: Only one usage of each socket address (protocol/network address/port) is normally permitted. (10048)
could not read ok from ADB Server
* failed to start daemon *
error: cannot connect to daemon
at Socket.<anonymous> (C:\Users\Raziff\AppData\Roaming\npm\node_modules\nativescript\lib\common\mobile\mobile-core\android-device-discovery.js:54:25)
at emitOne (events.js:77:13)
at Socket.emit (events.js:169:7)
at readableAddChunk (_stream_readable.js:146:16)
at Socket.Readable.push (_stream_readable.js:110:10)
at Pipe.onread (net.js:523:20)
Any way to fix this. I've tried it with various devices.
Have you checked your port? Your port which is 5037 probably is being used by other application. You can check your port using Windows Task Manager.
When you run tns more than 2 times It sometimes consumes your port, the thing you need to do is to run
netstat -a -o -n
You will get the list of tasks running on your machine.
You need to look for the 5037 port in the local address column, after you find it, check the process ID (PID) of the task.
Then kill it with
taskkill /f /pid 123456
Now you can continue with developement :)
What I discovered was there was a difference in ADB versions being used throughout the system. Here is the command I used to find them:
where /r C:\ adb.exe
This produced the results:
C:\Program Files\Expo XDE\resources\app\node_modules\xdl\binaries\windows\adb\adb.exe
C:\Program Files\Genymobile\Genymotion\tools\adb.exe
C:\Users\kyle\AppData\Local\Android\Sdk\platform-tools\adb.exe
C:\Users\kyle\AppData\Local\Android\Sdk\platform-tools\adb backup\adb.exe
Navigating to each directory and running:
adb.exe version
Allowed me to see that Expo was running ADB version:
Android Debug Bridge version 1.0.36
Revision fd9e4d07b0f5-android
While Genymotion using the custom SDK had version (c:\Users\kyle\AppData\Local\Android\Sdk\platform-tools\adb.exe):
Android Debug Bridge version 1.0.39
Revision 3db08f2c6889-android
As a test I took the adb files (adb.exe, AdbWinApi.dll, AdbWinUsbApi.dll) from
c:\Users\kyle\AppData\Local\Android\Sdk\platform-tools\adb.exe
and placed them into a backup folder. I then moved the adb files located at
c:\Program Files\Expo XDE\resources\app\node_modules\xdl\binaries\windows\adb\adb.exe
into that same location. I killed adb with:
adb kill-server
which caused a restart of the adb server automatically due to having my Genymotion device already running. I hit the "Restart" button inside of the Expo XDE and it immediately began working. Here is the log where I hit the restart button at 1:13:04 AM:
simply all adb.exe files must have same versions.
I'm continuing my adventure with Xamarin.
I'm developing an Xamarin Forms application with a Portable Class Libraries (PCL).
I have compiled and debugged my application by Android, but now, I'm interested to run the application in iOS to test in this platform.
I have a problem with the connection between my PC and the Mac.
I have a PC (Windows 8.1) with Visual Studio Community 2015 with Xamarin tools installed.
In my Mac Mini, I have installed OS X (v10.11.3), XCode (v7.2) and Xamarin Studio. I have logged in with my Xamarin account.
In the two machines I have the same Xamarin version.
I have followed the Xamarin walkthrough.
On Visual Studio I open the Xamarin Mac Agent. It finds my Mac Mini. Then it asks me the Mac credentials (user and password).
The login works at this point.
Then, in the solution, I set the iOS project as the startup project. I clean the solution, I build again and start the compile/debug process (F5).
In this point, the output retrieves a message:
1> Connecting to Mac server Macs-Mac-mini.local...
1>C:\Program Files (x86)\MSBuild\Xamarin\iOS\Xamarin.iOS.Windows.After.targets(54,5): warning : Could not authenticate the user using the existing ssh keys
1>C:\Program Files (x86)\MSBuild\Xamarin\iOS\Xamarin.iOS.Windows.After.targets(54,5): error : Unable to connect to Address='Macs-Mac-mini.local' with User='macmini
I have used Putty (SSH Client) to check with my user/password if I'm able to connect to Mac, and I have had success.
Into /Users/macmini2/.ssh/authorized_keys file (Mac machine) each time that I use the Xamarin Mac Agent, Visual Studio adds a new key entry (it adds the same repeated).
I see that perhaps the problem is related with ssh keys.
Why I have this problem? What am I doing wrong?
A thing that I have tested was openning the Xamarin project directly in Mac with Xamarin Studio, build it and run the simulator. It works.
I have seen other similar question, but I think that it doesn't have the same problem.
EDIT:
More specific information about the error when I try to compile/debug:
Could not authenticate the user using the existing ssh keys
Xamarin.Messaging.VisualStudio.MessagingAuthenticationException: Could not authenticate the user using the existing ssh keys ---> Renci.SshNet.Common.SshAuthenticationException: Permission denied (publickey).
en Renci.SshNet.ClientAuthentication.Authenticate(IConnectionInfoInternal connectionInfo, ISession session)
en Renci.SshNet.ConnectionInfo.Authenticate(ISession session)
en Renci.SshNet.Session.Connect()
en Renci.SshNet.BaseClient.Connect()
en Xamarin.Messaging.VisualStudio.MessagingService.<ConnectAsync>d__70.MoveNext()
--- Fin del seguimiento de la pila de la excepción interna ---
EDIT 2:
I have revised the troubleshooting Xamarin page, specifically that it says "Unable to authenticate with SSH keys. Please try to log in with credentials first".
I have run:
chmod og-w "$HOME"
grep sshd /var/log/system.log > "$HOME/Desktop/sshd.log"
cd Desktop
cat sshd.log
And the content of the file is:
Apr 18 09:23:28 Macs-Mac-mini sshd[769]: Authentication refused: bad ownership or modes for directory /Users/macmini2/.ssh
Apr 18 09:25:27 Macs-Mac-mini com.apple.xpc.launchd[1] (com.openssh.sshd.EE9A94ED-????-....-????-77254934B300[769]): Service exited with abnormal code: 1
Apr 18 09:59:39 Macs-Mac-mini sshd[1036]: Accepted keyboard-interactive/pam for macmini2 from 192.168.54.14 port 60413 ssh2
Apr 18 09:59:39 Macs-Mac-mini sshd: macmini2 [priv][1036]: USER_PROCESS: 1040 ttys000
But now I don't know what I have to do to solve it.
You have to try delete everything from
%localappdata%\Xamarin\MonoTouch
It helped me, I had the same (or similar) problem today.
I have found the solution about my problem. I have done the following steps:
In my Windows: I have removed the content from "%localappdata%\Xamarin\MonoTouch."
In Mac terminal: Remove the authorized_keys Mac file ("rm /Users/macmini2/.ssh/authorized_keys" in my case)
In Mac terminal: chmod g-w /Users/macmini2/
In Mac terminal: chmod 700 /Users/macmini2/.ssh/
In Mac terminal: Create a empty file: /Users/macmini2/.ssh/authorized_keys (with vim, for example)
In Mac terminal: chmod 600 /Users/macmini2/.ssh/authorized_keys
On Visual Studio: Login with Xamarin Mac Agent
On Visual Studio: Run the application with [Debug] - [iPhoneSimulator] - [iPhone 5 iOS 8.1]
And finally, the simulator runs on Mac computer.
This link helped me.
Xamarin has a Troubleshooting page with large focus on SSH issues:
Connection Troubleshooting
Specifically these two:
Log File Location
Mac – ~/Library/Logs/Xamarin-[MAJOR.MINOR]
Windows – %LOCALAPPDATA%\Xamarin\Logs
The log files can be located by browsing to Help > Xamarin > Zip Logs in Visual Studio.
"Unable to authenticate with SSH keys. Please try to log in with credentials first"
Known cause:
SSH security restriction – This message most often means that one of the files or directories in the fully qualified path of $HOME/.ssh/authorized_keys on the Mac has write permissions enabled for other or group members. Common fix: Run chmod og-w "$HOME" in a Terminal command prompt on the Mac. For details about which particular file or directory is causing the problem, run grep sshd /var/log/system.log > "$HOME/Desktop/sshd.log" in Terminal, and then open the sshd.log file from your Desktop and look for "Authentication refused: bad ownership or modes".
Furthermore there is this section, which does not directly match the error you are seeing but goes into some detail on SSH configuration and diagnosis:
"Couldn't connect to MacBuildHost.local. Please try again."
Reported causes:
Bug – A few users have seen this error message when attempting to log in to the build host using an Active Directory domain user account.
Bug – Some users have seen this error when attempting to connect to the build host by double-clicking the name of the Mac in the connection dialog. Possible workaround: Manually add the Mac using the IP address.
Bug #35971 – Some users have run across this error when using a wireless network connection between the Mac build host and Windows. Possible workaround: Move both computers to a wired network connection.
Bug #36642 – On Xamarin 4.0, this message will appear anytime the $HOME/.bashrc file on the Mac contains an error. (Starting with Xamarin 4.1, errors in the .bashrc file will no longer affect the connection process.) Workaround: Move the .bashrc file to a backup location (or delete it if you know you don't need it).
Limitation – This error can appear if the Mac build host is connected to a router that has no access to the internet (or if the Mac is using a DNS server that times out when asked for the reverse-DNS lookup of the Windows computer). Visual Studio will take roughly 30 seconds to retrieve the SSH fingerprint and eventually fail to connect.
Possible workaround: Add "UseDNS no" to the sshd_config file. Be sure to read about this SSH setting before changing it. See for example http://unix.stackexchange.com/questions/56941/what-is-the-point-of-sshd-usedns-option.
The following steps describe one way to change the setting. You will need to be logged in to an administrator account on the Mac to complete the steps.
Confirm the location of the sshd_config file by running ls /etc/ssh/sshd_config and ls /etc/sshd_config in a Terminal command prompt. For all of the remaining steps, be sure to use the location that does not return "No such file or directory".
Run cp /etc/ssh/sshd_config "$HOME/Desktop/" in Terminal to copy the file to your desktop.
Open the file from your Desktop in a text editor. For example you can run open -a TextEdit "$HOME/Desktop/sshd_config" in Terminal.
Add the following line at the bottom of the file:
UseDNS no
Remove any lines that say UseDNS yes to make sure the new setting takes effect.
Save the file.
Run sudo cp "$HOME/Desktop/sshd_config" /etc/ssh/sshd_config in Terminal to copy the edited file back into place. Enter your password if prompted.
Disable and re-enable Remote Login under System Preferences > Sharing > Remote Login to restart the SSH server.
I have just solved this problem!
It was nonsense.
To connect Visual Studio Xamarin project and simulate that on Mac when you get:
Couldn't connect to computername.local please try again later.
What you need to do next:
Follow the solution from xamarin community about mac connection
after this point if everything OK, you will connect, but if no..
Install XAMARIN STUDIO on MAC. After installation start XAMARIN studio, create your own app and run with simulator
Close app and try to connect again from Windows computer.
At this point you will make synchronization and that's all.
Problem solved! I hope this will be useful for somebody.
For me helped next solution:
1)On Windows open Visual Studio:
Tools=>Options=>Xamarin=>Other and click in Check Now
2)On Mac open Xamarin Studio Community (https://www.xamarin.com/download)
Xamarin Studio Community=>Check for Updates... (and download last one)
After updates all works fine.
I tried a few of the solutions mentioned here and had no success.
However (though not ideal) if I run Visual Studio in Administrator Mode I can successfully connect. Could be a work around for some until a better solution is found.
This is not perfect solution, but made success in my case
Your mac account should not contain any special characters- This is limitation in connection to mac from windows
company-mac1 --- wrong
comapanymac1 --- Correct
For what it's worth I just solved this issue by checking the logs as noted above and in the Xamarin Troubleshooting docs. It turned out to be mismatched iOS versions. Once I updated the Mac version it worked.
In my case, i installed mono sdk on my mac it solve the problem
http://www.mono-project.com/download/#download-mac
Ignored the agent that Visual Studio wizard showed. Something about the Mac computer name VS didn't understand.
I did 'Add Mac', used the IP address, then it connected. That was annoying.
Did you turn on remote login and that is the user/login that is currently logged into the machine? Also, have you tried connecting directly to the IP address instead of the DNS name?
I am on a client's network (different domain than mine) and my VS would never connect via the computer name. I always had to type in the IP address. Also, watch the out put for "Xamarin" in the Output panel/window and see if it gives any more helpful information.
I had this problem recently (despite having enabled Sharing on the OSX host and checking firewall) and it turned out that both OSX Machine and Windows Machine needed the exact same version of Xamarin.iOS and a restart.
Updating both, restarting both, solved the problem for me.
I think what fixed it for me was opening git bash then running ssh onto the mac box. After saying Y to trusting credentials it worked.
In my case I could not connect to XCode because "XCode" file wasn't located at the "Application" folder on MacOS. When the "XCode" app was moved to "Application" folder, I had connect.
Update Visual Studion on Mac and:
1) Delete on Mac - all files in .ssh (rm *)
2) Delete on Mac the folder .ssh
3) On Windows, generate your ssh key and transfer to MAC - for that Open Windows PowerShell and execute the follow commands:
[generate the key]
PS>ssh-keygen -t rsa -b 4096
[define the remote host variable]
PS>$REMOTEHOST="name_of_mac_user#ip_mac_machine"
[send the key to mac machine]
PS>scp "$env:USERPROFILE\.ssh\id_rsa.pub" "${REMOTEHOST}:~/tmp.pub"
[copy the key tmb.pub to authorized_keys file and set the permissions]
PS>ssh "$REMOTEHOST" "mkdir -p ~/.ssh && chmod 700 ~/.ssh && cat ~/tmp.pub >> ~/.ssh/authorized_keys && chmod 600 ~/.ssh/authorized_keys && rm -f ~/tmp.pub"
4) check on mac .ssh folder if the authorized_keys file is correct:
tail ./authorized_keys
5) check the permission for authorized_keys (-rw-------)
ls -al ./authorized_keys