首页 > 解决方案 > 我正在尝试使用 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.

标签: androidwamp

解决方案


http://10.0.2.2/login.php

而是使用 10.0.2.2 使用您的 IPv4 地址并添加您的端口号虽然对我有用


推荐阅读