Skip to content

Instantly share code, notes, and snippets.

@lisicnu
Forked from mohsenk/Gradle_Adb_Plugin.gradle
Created October 29, 2016 07:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lisicnu/bea670d0f932574c0a27297e4759b8dd to your computer and use it in GitHub Desktop.
Save lisicnu/bea670d0f932574c0a27297e4759b8dd to your computer and use it in GitHub Desktop.
Gradle task for connect adb to android device over wifi network
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"
}
@lisicnu
Copy link
Author

lisicnu commented Oct 29, 2016

fork

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment