【问题标题】:i am trying to connect to database using wamp but it throws file not found exception in android studio.How to solve this?我正在尝试使用 wamp 连接到数据库,但它会在 android studio 中引发 file not found 异常。如何解决这个问题?
【发布时间】:2020-05-15 18:50:55
【问题描述】:

所以我已经配置了 php 文件并且我的 wamp 尝试连接到数据库但它抛出一个错误我什至保留了网络安全证书但仍然抛出错误。

尝试过的解决方案 1. 新增 android:usesCleartextTraffic="true"。 2.将地址更改为ipv4地址。 3.增加安全文件 清单xml:

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.

【问题讨论】:

    标签: android wamp


    【解决方案1】:

    http://10.0.2.2/login.php

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

    【讨论】:

      【解决方案2】:

      您正在尝试连接到 127.0.0.1 而不是 10.0.0.2 10.0.0.2是设备的localhost,显然文件不在设备上

      您需要更新您的 /etc/hosts 文件以反映 localhost as 127.0.0.1 否则设备将尝试连接到自身

      【讨论】:

        猜你喜欢
        • 2020-05-15
        • 2021-03-19
        • 1970-01-01
        • 2022-01-12
        • 1970-01-01
        • 1970-01-01
        • 2020-10-01
        • 1970-01-01
        • 2023-03-25
        相关资源
        最近更新 更多