Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The WebView running in the emulator in Android studio cannot access internet, but Chrome can?

I installed Android studio 1.0.1 and followed this page https://developer.chrome.com/multidevice/webview/gettingstarted to wrap a website to an app.

However, I got the following error when running it in emulator.

Webpage not available

The webpage at https://..... could not be loaded because:

net::ERR_NAME_NOT_RESOLVED

However, I tried to click the link and it launched the website in Chrome without any problem.

like image 263
ca9163d9 Avatar asked Jan 02 '15 09:01

ca9163d9


People also ask

How do I enable internet on Android Emulator?

Go to your Android\Sdk\emulator folder and open command prompt. Type emulator -list-avds to see available emulator names. Type emulator -avd name-of-your-device -netdelay none -netspeed full -dns-server 8.8. 8.8 command and press enter.

Is Android WebView same as Chrome?

No, Chrome for Android is separate from WebView. They're both based on the same code, including a common JavaScript engine and rendering engine.

How do I enable internet on emulator?

If your emulator must access the internet through a proxy server, you can configure a custom HTTP proxy from the emulator's Extended controls screen. With the emulator open, click More , and then click Settings and Proxy. From here, you can define your own HTTP proxy settings.


2 Answers

This may sound kind of obvious, but make sure 3G is turned on in your emulator:enter image description here

To do so, turn on Cellular Data (on is the switch to the right):

enter image description here

Then notice the 3G symbol shows up above the signal strength symbol: enter image description here

I've been trying to manage connection state and stumbled onto this question and know that's a possible reason for that error. It's a little late, but hopefully helps someone down the line.

like image 195
Sum None Avatar answered Nov 05 '22 17:11

Sum None


It may be a bit late, but still. You have to make sure that you included ALL the following permissions.

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
like image 30
Ibragim Khavaev Avatar answered Nov 05 '22 18:11

Ibragim Khavaev