【问题标题】:"Failed to open QEMU pipe 'qemud:network': Invalid argument" error when trying to run app on android emulator尝试在 android 模拟器上运行应用程序时出现“无法打开 QEMU 管道‘qemud:network’:无效参数”错误
【发布时间】:2021-09-29 08:06:39
【问题描述】:

我一直在努力学习本教程:

https://www.youtube.com/watch?v=SBzfsCFgGdo&list=PLDGYn1fFRgEN1zsbOLRCdapIZlb0Y9Bas&index=3

尝试在模拟器上运行应用程序时遇到以下错误:

2021-07-22 02:14:47.311 442-442/? E/netmgr: qemu_pipe_open_ns:62: Could not connect to the 'pipe:qemud:network' service: Invalid argument
2021-07-22 02:14:47.311 442-442/? E/netmgr: Failed to open QEMU pipe 'qemud:network': Invalid argument
2021-07-22 02:14:49.051 444-444/? E/wifi_forwarder: qemu_pipe_open_ns:62: Could not connect to the 'pipe:qemud:wififorward' service: Invalid argument
2021-07-22 02:14:49.051 444-444/? E/wifi_forwarder: RemoteConnection failed to initialize: RemoteConnection failed to open pipe

互联网上的所有解决方案都围绕着在清单文件中包含“android:usesCleartextTraffic="true"”,但我这样做了,但没有更好的结果。

我的代码:

MainActivity.java:

package com.example.testapp;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.widget.TextView;
import android.widget.Toast;

import org.jetbrains.annotations.NotNull;

import java.io.IOException;

import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        OkHttpClient client = new OkHttpClient();
        Request request = new Request.Builder().url(" http://192.168.1.246:5000/").build();

        client.newCall(request).enqueue(new Callback() {
            @Override
            public void onFailure(@NotNull Call call, @NotNull IOException e) {
                Toast.makeText(MainActivity.this, "network not found", Toast.LENGTH_LONG).show();
            }

            @Override
            public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
                TextView textView = findViewById(R.id.textView1);
                textView.setText(response.body().string());
            }
        });
    }
}

AndroidManifest.xml:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.testapp">
    <uses-permission android:name="android.permission.INTERNET" />
    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/Theme.TestApp"
        android:usesCleartextTraffic="true">
        <activity android:name=".MainActivity"
            android:exported = "false">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

Flask 服务器:

from flask import Flask, request

app = Flask(__name__)

@app.route('/')
def hello_world():
    print("request")
    return 'hello honey'

if __name__ == "__main__":
    app.run()

【问题讨论】:

  • 而不是包含指向外部资源的链接(youtube 链接),而是包含您正在遵循的实际步骤作为问题的一部分。该链接可能会随着时间的推移而中断,并不是每个人都可以访问它。 stackoverflow.com/help/how-to-ask

标签: java android android-studio android-emulator qemu


【解决方案1】:

这个错误可能是由于两个原因:

  1. 由于您的 android 模拟器/设备版本。
  2. 由于您的 java 或 xml 文件中存在一些错误。

首先,将您当前的 minSdkVersion 更改为其他版本,最好低于 23。 然后检查您的 logcat 是否在您的代码中给出了一些错误。这很可能是一个导入错误。

就我而言,我将 minSdkVersion 从 26 更改为 17。 它对我有用。希望它也适用于您。

【讨论】:

    猜你喜欢
    • 2019-05-14
    • 1970-01-01
    • 2014-03-23
    • 1970-01-01
    • 2017-09-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-10-17
    相关资源
    最近更新 更多