Skip to content

Instantly share code, notes, and snippets.

@doitian
Created May 29, 2013 22:59
Show Gist options
  • Save doitian/5674505 to your computer and use it in GitHub Desktop.
Save doitian/5674505 to your computer and use it in GitHub Desktop.
Install android app, start it and forward jdwp port to local for jdb
<target name="run" depends="debug,install">
<xpath input="${manifest.abs.file}"
expression="/manifest/application/activity/@android:name" output="project.app.activity" />
<exec executable="${sdk.dir}/platform-tools/adb">
<arg value="shell" />
<arg value="am" />
<arg value="force-stop" />
<arg value="${project.app.package}" />
</exec>
<exec executable="${sdk.dir}/platform-tools/adb">
<arg value="shell" />
<arg value="am" />
<arg value="start" />
<arg value="-D" />
<arg value="${project.app.package}/.${project.app.activity}" />
</exec>
</target>
<!-- Local port forwarded from remote jdwp -->
<property name="jdb.port" value="8888" />
<target name="jdb" depends="run">
<exec executable="${sdk.dir}/platform-tools/adb" outputproperty="jdb.jdwp.all">
<arg line="${adb.device.arg}" />
<arg value="jdwp" />
</exec>
<exec executable="tail" outputproperty="jdb.jdwp.last" inputstring="${jdb.jdwp.all}">
<arg line="-n 1" />
</exec>
<exec executable="${sdk.dir}/platform-tools/adb">
<arg line="${adb.device.arg}" />
<arg value="forward" />
<arg value="tcp:${jdb.port}" />
<arg value="jdwp:${jdb.jdwp.last}" />
</exec>
<echo>Run command: jdb -attach localhost:${jdb.port}</echo>
</target>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment