相关疑难解决方法(0)

Android 8:不允许使用Cleartext HTTP流量

我收到了Android 8用户的报告,我的应用(使用后端Feed)没有显示内容.经过调查,我发现在Android 8上发生以下异常:

08-29 12:03:11.246 11285-11285/ E/: [12:03:11.245, main]: Exception: IOException java.io.IOException: Cleartext HTTP traffic to * not permitted
at com.android.okhttp.HttpHandler$CleartextURLFilter.checkURLPermitted(HttpHandler.java:115)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:458)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:127)
at com.deiw.android.generic.tasks.AbstractHttpAsyncTask.doConnection(AbstractHttpAsyncTask.java:207)
at com.deiw.android.generic.tasks.AbstractHttpAsyncTask.extendedDoInBackground(AbstractHttpAsyncTask.java:102)
at com.deiw.android.generic.tasks.AbstractAsyncTask.doInBackground(AbstractAsyncTask.java:88)
at android.os.AsyncTask$2.call(AsyncTask.java:333)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:245)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
at java.lang.Thread.run(Thread.java:764)
Run Code Online (Sandbox Code Playgroud)

(我删除了包名,URL和其他可能的标识符)

在Android 7及更低版本上一切正常,我没有设置android:usesCleartextTrafficManifest(并设置它true没有帮助,无论如何这是默认值),我也没有使用网络安全信息.如果我打电话NetworkSecurityPolicy.getInstance().isCleartextTrafficPermitted(),它会返回falseAndroid 8,true对于旧版本,使用相同的apk文件.我试图在关于Android O的Google信息上找到一些提及,但没有成功.

https android http

782
推荐指数
19
解决办法
41万
查看次数

如何从Android设备访问本地主机?

我可以使用Android模拟器访问我的笔记本电脑网络服务器,我使用10.0.2.2:portno 效果很好.

但是当我连接我真正的Android手机时,手机浏览器无法连接到笔记本电脑上的同一个Web服务器.手机通过USB线连接到笔记本电脑.如果我运行adb devices命令,我可以看到我的手机.

我错过了什么?

android

482
推荐指数
20
解决办法
58万
查看次数

如何在Android模拟器中连接localhost?

我在localhost中创建了一个php脚本,我正在连接它,httpClient但是我遇到了问题.

请告诉我如何从模拟器连接到localhost的php文件?

localhost httpconnection android-emulator androidhttpclient

99
推荐指数
7
解决办法
6万
查看次数

如何在新版本的Android Studio中的模拟器中配置代理?

问题描述

我需要通过 Android Studio 在模拟器中手动配置代理。从Android官方文档来看,建议可以在模拟器扩展控件的“设置”选项卡中进行此更改。问题是,在我看来,这个文档已经过时了,因为这个设置不再显示在 Android Studio 模拟器扩展控件的“设置”选项卡中。

文档

有代理

我的安卓工作室

没有代理

我的 Android Studio 版本

Android Studio Bumblebee | 2021.1.1
Build #AI-211.7628.21.2111.8092744, built on January 19, 2022
Runtime version: 11.0.11+9-b60-7590822 amd64
VM: OpenJDK 64-Bit Server VM by Oracle Corporation
Windows 10 10.0
GC: G1 Young Generation, G1 Old Generation
Memory: 1280M
Cores: 8
Registry: external.system.auto.import.disabled=true
Non-Bundled Plugins: com.wakatime.intellij.plugin (13.1.10), wu.seal.tool.jsontokotlin (3.7.2), org.jetbrains.kotlin (211-1.6.10-release-923-AS7442.40), com.developerphil.adbidea (1.6.4), org.jetbrains.compose.desktop.ide (1.0.0), ru.adelf.idea.dotenv (2021.2), org.intellij.plugins.markdown (211.7142.37)
Run Code Online (Sandbox Code Playgroud)

ide android android-studio

44
推荐指数
2
解决办法
2万
查看次数

如何测试使用Angular CLI ng创建的应用程序是否可以从其他设备进行测试?

我从头开始使用Angular CLI生成应用程序.CLI版本angular-cli: 1.0.0-beta.11-webpack.2

我试图从我的智能手机测试它,但我得到Connection拒绝.

所以,我ng serve在我的笔记本电脑上运行并尝试访问该应用程序:

  • 从笔记本电脑,使用localhost:工作
  • 从笔记本电脑,使用IP:连接被拒绝
  • 从智能手机,使用IP:连接被拒绝

这曾用于以前的SystemJS版CLI.我检查过我没有运行防火墙.

我该如何修复或调试此错误?

我正在使用Mac.

networking angular-cli angular

33
推荐指数
2
解决办法
2万
查看次数

无法连接到 localhost/127.0.0.1 android

我是 android 开发的新手,并试图通过改造库在 android 中调用本地 .NET web api 服务。在 IIS 上启动我的 web api 后,我收到此错误无法连接到 localhost/127.0.0.1 android。

当我按照建议的http://themakeinfo.com/2015/04/retrofit-android-tutorial/做同样的事情时,它工作正常,但我的本地主机服务没有从 android 调用

我的服务网址是, http://localhost:52511/api/Values/getAllStudents/5

它也在浏览器中为我提供了 XML 格式的输出。

我也试着用,

public interface gitapi {
    @GET("/api/Values/GetProduct/{id}")      //here is the other url part.best way is to start using /
    public void getFeed(@Path("id") int id, Callback<gitmodel> response);
}

public class gitmodel {
    public int studentId;
    public String studentName;
    public String studentAddress;
}


String API = "http://10.0.2.2:52511";
public void CallService(View view){

        RestAdapter restAdapter = new RestAdapter.Builder().setEndpoint(API).build();
        gitapi …
Run Code Online (Sandbox Code Playgroud)

android androidhttpclient retrofit

10
推荐指数
3
解决办法
4万
查看次数

无法从 Android 应用程序连接到 localhost API

我是 Django 的新手。我创建了一个名为 API 的 API http://127.0.0.1:8000/api/update/1/,它可以在浏览器和 Postman 应用程序中完美运行。

但是,当我尝试从 Android 应用程序访问 API 时,它返回 NULL。

当 API 如下时,android 代码有效。

http://newsapi.org/v1/articles?source=bbc-news&sortBy=top&apiKey=8190df9eb51445228e397e4185311a66
Run Code Online (Sandbox Code Playgroud)

但是,当 API 如下时它不起作用,即使以下 API 在我在同一台 PC 上运行的浏览器和 Postman 应用程序中工作得很好。

http://127.0.0.1:8000/api/update/1/
Run Code Online (Sandbox Code Playgroud)

我附上了进行 API 调用的代码。

protected String doInBackground(String... args) {
    String xml = "";
    String api = "http://127.0.0.1:8000/api/update/1/"; // returns NULL works in Postman app and in the browser
    // String api = "http://newsapi.org/v1/articles?source=bbc-news&sortBy=top&apiKey=8190df9eb51445228e397e4185311a66"; // works in all places
    String urlParameters = "";
    xml = Function.excuteGet(api, urlParameters);
    return  xml;
}
Run Code Online (Sandbox Code Playgroud)

谁能帮我这个?提前致谢。

java api django android localhost

9
推荐指数
3
解决办法
3万
查看次数

我的计算机通过VPN连接,Android模拟器无法访问本地Intranet站点

我远程工作并通过VPN客户端连接到我的办公室.我的计算机上的每个程序都可以访问办公室网络,浏览器可以连接到Intranet站点(例如http://myportal/).当我打开Android模拟器并打开浏览器时,它无法访问任何内部网站点.

知道为什么,或者如何让它做到这一点?

编辑:它似乎能够通过IP访问它就好了,所以它看起来像一个DNS问题.知道如何让模拟器使用我的连接设置使用的DNS地址吗?

编辑2:我尝试使用绑定到我的VPN连接的DNS启动模拟器,这似乎没有帮助 emulator -avd Default -dns-server 192.16.200.100,192.16.4.2

android adt android-emulator eclipse-adt

8
推荐指数
1
解决办法
2505
查看次数

从Android Emulator连接到LocalHost/10.0.2.2超时

尽管在StackOverflow中多次询问过这个问题并且我经历了很多问题,但仍无法解决我的问题,或者我无法找出问题的根本原因.因此,发布一个新问题.

以下是我经历的链接列表 -

  1. 如何从Eclipse中的Android Emulator连接到我的http:// localhost Web服务器

  2. 从Android模拟器访问localhost:port

  3. 如何从Android设备访问本地主机?

  4. 如何在android模拟器中连接localhost?

这是我的代码 -

protected Void doInBackground(Void... params)
    {
        try
        {
            HttpURLConnection connection = null;

            URL url = new URL("http://10.0.2.2:8080/android_connect/user_registration.php");
            connection = (HttpURLConnection)url.openConnection();
            connection.setDoOutput(true);
            connection.setDoInput(true);
            connection.setRequestMethod("POST");
            connection.setUseCaches(false);
            connection.setConnectTimeout(720000000);
            connection.setReadTimeout(72000000);
            connection.connect();

            OutputStreamWriter output = new OutputStreamWriter(connection.getOutputStream());
            output.write(emp_details.toString());
            output.flush();
            output.close();

            HttpResult = connection.getResponseCode();

            connection.disconnect();
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }
        return null;
    }
Run Code Online (Sandbox Code Playgroud)

我试图通过WAMP服务器使用PHP连接Android与MySQL数据库.PHP文件(user_registration.php)保存在以下路径中 -

C:\wamp\www\android_connect
Run Code Online (Sandbox Code Playgroud)

现在执行代码后,我收到一个错误,如" java.net.SocketTimeoutException:在720000000ms之后无法连接到/10.0.2.2(端口8080):isConnected失败:ETIMEDOUT(连接超时) ".

我通过了特定的链接来解决这个问题 -

Android连接到localhost

但无法理解它是如何解决的!:)

在这种情况下你能帮我吗?请注意我正在使用Android Studio进行构建.

提前致谢!

php java post android localhost

7
推荐指数
2
解决办法
2万
查看次数

离子 4 网::ERR_CONNECTION_REFUSED(http://localhost/)

我遇到了一个问题,当我尝试创建基于 Ionic 4 的移动前端应用程序时,但是当我在 android studio 模拟器上使用cordova 运行它时会出现一个 net:ERR_CONNECTION_REFUSED( http://localhost/ )。这是我使用的

Angular CLI: 7.1.4
Node: 8.9.4
OS: win32 x64
Ionic version   4.5.0
Run Code Online (Sandbox Code Playgroud)

我的 config.xml

配置文件

android ionic-framework ionic4 angular7

5
推荐指数
2
解决办法
7451
查看次数