Skip to content

Instantly share code, notes, and snippets.

@leandrowd
Created February 27, 2014 01:26
Show Gist options
  • Save leandrowd/9242446 to your computer and use it in GitHub Desktop.
Save leandrowd/9242446 to your computer and use it in GitHub Desktop.
# Debugging Android Stock Browser using Weinre and Ngrok
This doc will show how to debug any mobile browser that doesn't have a good debug tool.
If your local website can be exposed to your device, you don't need install the Ngrok.
## Step-by-step
- Install the weinre app: `sudo npm -g install weinre`
- After that, You can start it typing: `weinre`
- Add the script to you page `<script src="http://<localhost|your-ip>:8080/target/target-script-min.js#anonymous"></script>`
If you are not able to expose your machine's ip, try using ngrok.
You can download it here:
- [Mac](https://dl.ngrok.com/darwin_amd64/ngrok.zip)
- [Linux](https://dl.ngrok.com/linux_386/ngrok.zip)
- [Windows](https://dl.ngrok.com/windows_386/ngrok.zip)
- [Other plataforms](https://ngrok.com/)
- Unzip it: `$ unzip /path/to/ngrok.zip`
- Make a file `~/.ngrok` with this content:
```
auth_token: <YOUR-TOKEN>
tunnels:
debug:
proto:
http: "8080"
project:
subdomain: <alias>
proto:
http: “80"
```
- Replace `<YOUR-TOKEN>` by the token generated in `http://ngrok.com`
- Replace `<alias>` by something like `local.idol.com` - you will access your local site on your mobile through this alias
- Change the weinre script tag to `http://debug.ngrok.com/target/target-script-min.js#anonymous`
- Run it: `$ ./ngrok debug project`
- Open in your machine the url `http://localhost:8080` to access the debug tool
- Access your website using the alias on the Android stock browser
- Enjoy!
## References:
- http://people.apache.org/~pmuellr/weinre/docs/latest/
- https://ngrok.com/
- http://www.broken-links.com/2013/06/28/remote-debugging-with-weinre/
@rmariuzzo
Copy link

Thanks, that's great for debugging Android stock browser.

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