android - 我正在尝试使用 wamp 连接到数据库,但它会在 android studio 中引发 file not found 异常。如何解决这个问题?
问题描述
所以我已经配置了 php 文件,我的 wamp 试图连接到数据库,但它抛出了一个错误,我什至保留了网络安全证书,但仍然抛出了错误。
尝试过的解决方案 1. 添加了 android:usesCleartextTraffic="true"。2.将地址更改为ipv4地址。3.增加安全文件Manifestxml:
android:networkSecurityConfig="@xml/network_security_config";
network_security_config.xml:
<?xml version="1.0" encoding="utf-8"?>
<network-security-config xmlns:android="http://schemas.android.com/apk/res/android">
<debug-overrides>
<trust-anchors>
<certificates src="user" overridePins="true"/>
</trust-anchors>
</debug-overrides>
</network-security-config>
错误:
W/IInputConnectionWrapper: finishComposingText on inactive InputConnection
D/NetworkSecurityConfig: Using Network Security Config from resource network_security_config debugBuild: true
W/System.err: java.io.FileNotFoundException: http://10.0.2.2/login.php
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:250)
at com.example.mysqltest.BackgroundWorker.doInBackground(BackgroundWorker.java:46)
at com.example.mysqltest.BackgroundWorker.doInBackground(BackgroundWorker.java:19)
at android.os.AsyncTask$2.call(AsyncTask.java:304)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:243)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:761)
D/EGL_emulation: eglMakeCurrent: 0x9d285120: ver 2 0 (tinfo 0x9d2831f0)
D/EGL_emulation: eglMakeCurrent: 0x9d285120: ver 2 0 (tinfo 0x9d2831f0)
W/InputEventReceiver: Attempted to finish an input event but the input event receiver has already been disposed.
Process 13292 terminated.
解决方案
而是使用 10.0.2.2 使用您的 IPv4 地址并添加您的端口号虽然对我有用
推荐阅读
- node.js - ReactJS,NodeJS,为我的应用程序使用一次性密码是否安全?
- java - JavaFX Connect 4 游戏获胜方法
- flutter - 如何将简单数据从`secondpage`发送到`mainpage`(有状态到有状态)
- javascript - 无法使用 React Hooks 渲染功能组件
- c# - 运行我的测试时无法在 ASP.NET 核心中调用 API DELETE (405 Method Not Allowed)。但它大摇大摆地工作
- apache-spark - Pyspark:如何输入文本文件,使其被句号分割
- sql - SQL Server 中的动态函数问题
- python - 如果没有指定评分,则传递的估计器应该有一个 'score' 方法
- node.js - 通过使用 express 在 Nextjs 中刷新页面丢失查询字符串
- vue.js - 元标记在 Nuxt.js 应用程序的页面源中无法正确显示