android sync manager wifi pc,Android Studio - Android Emulator Wifi Connected with No Internet

解决Android Emulator无网络问题:配置DNS与构建流程
博客作者Vikram分享了如何解决Android模拟器通过路由器连接时无法正常下载依赖并导致构建失败的问题。问题在于模拟器使用了非谷歌DNS,而谷歌服务插件依赖于谷歌DNS来获取依赖。解决方案是将谷歌DNS(8.8.8.8)设置在网络设置之后,确保依赖下载,然后通过命令行启动模拟器指定DNS为8.8.8.8,使模拟器具备网络功能。对于React Native开发者,Vikram提供了bash脚本来启动不同类型的模拟器。

@TheBaj : I figured the problem with this and fixed it. The problem is when you are connected through the router, the androidwifi in your emulator uses the settings and the sets the DNS to something other than 8.8.8.8 which is the google DNS(I presume this is kinda mandatory setting for the androidwifi to gain internet access). But if i change the DNS in my network settings, the google-services plugin which fetches your dependencies especially the one's getting downloaded from jcenter() will not be downloaded and hence your sync will fail which eventually fails your build.

So the trick is that you have your google DNS(8.8.8.8) configured in your network settings after your default router settings - this part takes care of downloading the dependencies from jcenter() and the sync and build succeeds.

Now launch your emulator with emulator @Nexus_5X_API_27 -dns-server 8.8.8.8 command from the terminal which forces the emulator to use 8.8.8.8 as its DNS and the emulator will have internet.

I am working on a react-native app, so for me android studio is needless and i have configured my bashrc to launch the different emulators as follows,

function emunex5 {

emulator @Nexus_5X_API_27 -dns-server 8.8.8.8

}

function emunex6 {

emulator @Nexus_6_API_27 -dns-server 8.8.8.8

}

function emupix {

emulator @Pixel_XL_API_27 -dns-server 8.8.8.8

}

So from one terminal i launch the emulator of my choice and then run the build on another terminal which runs my app on the launched emulator and MY FREAKING EMULATOR HAS INTERNET ACCESS. :)

Try this out and i hope this helps.

Thanks,

Vikram

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值