Android Studio Emulator在Linux下无法连接到Proxy Server后面的Internet

我无法连接Android Studio模拟器到代理后面的Internet。

我在android Manifest.xml中启用了权限

<uses-permission android:name="android.permission.INTERNET" /> 

在USBdebugging模式下,该应用程序运行良好。 这是我在模拟器上运行应用程序时得到的错误。 以下是我的Logcat。

 D/makeGitHubSearchQuery: Inside Function D/makeGitHubSearchQuery: HTTP D/makeGitHubSearchQuery: https://api.github.com/search/repositories?q=HTTP&sort=stars D/OnOptionsItemSelected: action_search W/System.err: java.net.UnknownHostException: Unable to resolve host "api.github.com": No address associated with hostname W/System.err: at java.net.InetAddress.lookupHostByName(InetAddress.java:470) W/System.err: at java.net.InetAddress.getAllByNameImpl(InetAddress.java:252) W/System.err: at java.net.InetAddress.getAllByName(InetAddress.java:215) W/System.err: at com.android.okhttp.internal.Network$1.resolveInetAddresses(Network.java:29) W/System.err: at com.android.okhttp.internal.http.RouteSelector.resetNextInetSocketAddress(RouteSelector.java:188) W/System.err: at com.android.okhttp.internal.http.RouteSelector.nextProxy(RouteSelector.java:157) W/System.err: at com.android.okhttp.internal.http.RouteSelector.next(RouteSelector.java:100) W/System.err: at com.android.okhttp.internal.http.HttpEngine.createNextConnection(HttpEngine.java:357) W/System.err: at com.android.okhttp.internal.http.HttpEngine.nextConnection(HttpEngine.java:340) W/System.err: at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:330) W/System.err: at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:248) W/System.err: at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:433) W/System.err: at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:384) W/System.err: at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:231) W/System.err: at com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.getInputStream(DelegatingHttpsURLConnection.java:210) W/System.err: at com.android.okhttp.internal.huc.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java) W/System.err: at com.example.android.datafrominternet.utilities.NetworkUtils.getResponseFromHttpUrl(NetworkUtils.java:76) W/System.err: at com.example.android.datafrominternet.MainActivity$GithubQueryTask.doInBackground(MainActivity.java:77) W/System.err: at com.example.android.datafrominternet.MainActivity$GithubQueryTask.doInBackground(MainActivity.java:71) W/System.err: at android.os.AsyncTask$2.call(AsyncTask.java:295) W/System.err: at java.util.concurrent.FutureTask.run(FutureTask.java:237) W/System.err: at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234) W/System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113) W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588) W/System.err: at java.lang.Thread.run(Thread.java:818) W/System.err: Caused by: android.system.GaiException: android_getaddrinfo failed: EAI_NODATA (No address associated with hostname) W/System.err: at libcore.io.Posix.android_getaddrinfo(Native Method) W/System.err: at libcore.io.ForwardingOs.android_getaddrinfo(ForwardingOs.java:55) W/System.err: at java.net.InetAddress.lookupHostByName(InetAddress.java:451) 

请指导我在Android模拟器中设置代理设置。

使用此命令可以使用所需的代理打开模拟器。

 emulator -avd [emulator_name] -http-proxy [proxy ip address]:[port] 

官方文档