-
-
Save pellea/9d1c39bbc561f781d4190f1d1439f653 to your computer and use it in GitHub Desktop.
$currentSript = $PSScriptRoot + "\adb-start.ps1" | |
$adbPath = "C:\Program Files (x86)\Android\android-sdk\platform-tools" | |
$adbPort = 5037 | |
$adbListenAddress = '0.0.0.0' | |
$adbConnectAddress = '127.0.0.1' | |
$currentPrincipal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent()) | |
if ($currentPrincipal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) -eq $FALSE) | |
{ | |
Start-Process "powershell.exe" -ArgumentList $currentSript -WindowStyle hidden -Verb runAs | |
} | |
# Set ADB path | |
Set-Location $adbPath | |
# Remove port mapping | |
netsh interface portproxy delete v4tov4 listenport=$adbPort listenaddr=$adbListenAddress | |
# Kill server | |
./adb.exe kill-server | |
# Start server | |
./adb.exe start-server | |
# Add port mapping | |
netsh interface portproxy add v4tov4 listenport=$adbPort listenaddr=$adbListenAddress connectport=$adbPort connectaddr=$adbConnectAddress | |
# Display portproxy | |
netsh interface portproxy show v4tov4 | |
# Start WSL | |
wsl --exec exit | |
# Remove firewall rule for WSL | |
Set-NetFirewallProfile -DisabledInterfaceAliases "vEthernet (WSL)" |
You usually get this kind of error when the ADB server is not started.
The first script breaks my windows ADB and Pellea's answer still doesn't make it. I dunno what else I should do to make this work...
@angelod1as If you don't want to use WSL you can simply remove the port mapping and restart your computer. There is no other windows settings changed. So if anything is still broken after that, I don't think that's from the script. You can also start again the environment using Visual Studio > Tools > Android > restart adb server.
How to remove the DisabledInterfaceAliases
? @pellea
How to remove the
DisabledInterfaceAliases
? @pellea
You can enable the firewall again in the normal windows settings UI.
A screenshot would be helpful @pellea
Anyways on newer version of wsl we can access the windows version of adb inside wsl buy using adb.exe devices
To make thinks easier we can create an alias alias adb='adb.exe'
in wsl
I followed your tips and when I run 'adb devices' on powershell this error appears:
adb.exe: failed to check server version: protocol fault (couldn't read status): No error