我收到了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信息上找到一些提及,但没有成功.
我可以使用Android模拟器访问我的笔记本电脑网络服务器,我使用10.0.2.2:portno
效果很好.
但是当我连接我真正的Android手机时,手机浏览器无法连接到笔记本电脑上的同一个Web服务器.手机通过USB线连接到笔记本电脑.如果我运行adb devices命令,我可以看到我的手机.
我错过了什么?
我在localhost中创建了一个php脚本,我正在连接它,httpClient但是我遇到了问题.
请告诉我如何从模拟器连接到localhost的php文件?
我需要通过 Android Studio 在模拟器中手动配置代理。从Android官方文档来看,建议可以在模拟器扩展控件的“设置”选项卡中进行此更改。问题是,在我看来,这个文档已经过时了,因为这个设置不再显示在 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) 我从头开始使用Angular CLI生成应用程序.CLI版本angular-cli: 1.0.0-beta.11-webpack.2
我试图从我的智能手机测试它,但我得到Connection拒绝.
所以,我ng serve在我的笔记本电脑上运行并尝试访问该应用程序:
localhost:工作这曾用于以前的SystemJS版CLI.我检查过我没有运行防火墙.
我该如何修复或调试此错误?
我正在使用Mac.
我是 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) 我是 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)
谁能帮我这个?提前致谢。
我远程工作并通过VPN客户端连接到我的办公室.我的计算机上的每个程序都可以访问办公室网络,浏览器可以连接到Intranet站点(例如http://myportal/).当我打开Android模拟器并打开浏览器时,它无法访问任何内部网站点.
知道为什么,或者如何让它做到这一点?
编辑:它似乎能够通过IP访问它就好了,所以它看起来像一个DNS问题.知道如何让模拟器使用我的连接设置使用的DNS地址吗?
编辑2:我尝试使用绑定到我的VPN连接的DNS启动模拟器,这似乎没有帮助 emulator -avd Default -dns-server 192.16.200.100,192.16.4.2
尽管在StackOverflow中多次询问过这个问题并且我经历了很多问题,但仍无法解决我的问题,或者我无法找出问题的根本原因.因此,发布一个新问题.
以下是我经历的链接列表 -
这是我的代码 -
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 Studio进行构建.
提前致谢!
我遇到了一个问题,当我尝试创建基于 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
