How to connect your android emulator to the internet from the mac terminal.
This is one issue that bugged me for a long while 😭, I was learning a flutter course and while trying to preview my app on the emulator, I found out I couldn't view the NetworkImage widget. It was quite frustrating and I tried everything I could, including spending a lot of data upgrading things that didn't need upgrades.
Without much talk let's get started 😋.
Step One: Add Google DNS 8.8.8.8 to your wifi DNS
So the first thing you need to do is to add google DNS 8.8.8.8 to your wifi DNS. If you've already done it, feel free to skip to the next step:
- Click on the wifi icon located at the top of your mac, and from the dropdown, click on "open network preferences".
- Make sure the wifi your Pc is currently using is selected then click on "Advanced Settings".
- On the page that opens click on the DNS tab.
- You should see to columns, one showing the DNS servers and another showing search domains, your only concern is the column with DNS servers. Click on the plus button close to the bottom of the column. It should a new server 0.0.0.0 to the list of DNS servers.
- Edit the 0.0.0.0 to 8.8.8.8.
- Click Ok and that should be it.
Step Two: Launch emulator from Mac Terminal
- Open your Mac Terminal
- Input the following “cd ~/Library/Android/sdk”
- Then input this “./emulator/emulator -avd [your emulator name] -dns-server 8.8.8.8”
And that's it, you should be just fine!😉. Thanks and feel free to leave comments.
Also check out my article on solving the “missing emulator engine program for ‘x86’ cpu” error when trying to run emulators from Mac Terminal