Last active
August 30, 2023 00:42
-
-
Save mohsenk/18972afd9a89db827f4a to your computer and use it in GitHub Desktop.
Gradle task for connect adb to android device over wifi network
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import groovy.swing.SwingBuilder | |
task adbConnect(type: Exec) { | |
doFirst { | |
new SwingBuilder().edt { | |
dialog(modal: true, | |
title: 'Enter password', | |
alwaysOnTop: true, | |
resizable: false, | |
locationRelativeTo: null, | |
pack: true, | |
show: true | |
) | |
{ | |
vbox { // Put everything below each other | |
label(text: "Please enter your Android device IP") | |
input = textField() | |
button(defaultButton: true, text: 'Connect', actionPerformed: { | |
def device_ip = input.text; | |
println "Connecting to Device With IP : $device_ip"; | |
def adb = "$System.env.ANDROID_HOME/platform-tools/adb.exe" | |
executable adb | |
args "connect", device_ip | |
dispose(); // Close dialog | |
}) | |
} | |
} | |
} | |
} | |
} | |
task adbDevices(type: Exec) { | |
executable System.getenv("ANDROID_HOME") + "\\platform-tools\\adb.exe" | |
args "devices" | |
} | |
task adbLogCat(type: Exec) { | |
executable System.getenv("ANDROID_HOME") + "\\platform-tools\\adb.exe" | |
args "logcat" | |
} |
Finally a script that works for me ! Bless you!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks to this magic script.