Android-AVD打不开app,显示xxx has stopped的一种报错解决方式!!!

在启动AVD时遇到无法初始化DirectSoundCapture错误,原因是没有可用的声音驱动程序或指定的GUID不是有效的DirectSound设备ID。解决方法是打开并启用声音设备。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

启动AVD,居然打不开项目,还报一堆错!!!(类似说的是没有声音驱动程序或者声音设备)

1:19 Emulator: dsound: Could not initialize DirectSoundCapture

1:19 Emulator: dsound: Reason: No sound driver is available for use, or the given GUID is not a valid DirectSound device ID

1:19 Emulator: dsound: Attempt to initialize voice without DirectSoundCapture object

1:19 Emulator: dsound: Attempt to initialize voice without DirectSoundCapture object

1:19 Emulator: audio: Failed to create voice `goldfish_audio_in'

1:19 Emulator: D:\application\develop\sdk\emulator\qemu\windows-x86_64\qemu-system-x86_64.exe: warning: opening audio input failed

1:19 Emulator: dsound: Attempt to initialize voice without DirectSoundCapture object

1:19 Emulator: dsound: Attempt to initialize voice without DirectSoundCapture object

1:19 Emulator: audio: Failed to create voice `adc'

解决:(打开禁用的声音设备就OK了!!!)

 

 

 

 

我正在完成移动智能设备应用开发课程设计,设计要求是在Android Studio软件上设计一个简易的计算器。 以下是布局文件代码: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/whq" android:orientation="vertical"> <TextView android:id="@+id/textView" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" android:text="49吴俊廷" android:gravity="center" android:textColor="#000000" android:textSize="35sp" /> <TextView android:id="@+id/firstNumView" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" /> <TextView android:id="@+id/operatorView" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" /> <TextView android:id="@+id/secondNumView" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" /> <TextView android:id="@+id/resultView" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" /> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" android:orientation="horizontal"> <Button android:id="@+id/btnClear" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_weight="1" android:background="#AEACB7DD" android:alpha="0.5" android:text="c" /> <Button android:id="@+id/btnBack" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_weight="1" android:alpha="0.5" android:text="√" android:background="#AEACB7DD" /> <Button android:id="@+id/btnPercent" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_weight="1" android:background="#AEACB7DD" android:alpha="0.5" android:text="%" /> <Button android:id="@+id/btnAdd" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_weight="1" android:background="#AEACB7DD" android:alpha="0.5" android:text="+" /> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" android:background="#AEACB7DD" android:orientation="horizontal"> <Button android:id="@+id/btn7" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_weight="1" android:alpha="0.5" android:background="#AEE9F0FF" android:text="7" /> <Button android:id="@+id/btn8" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_weight="1" android:alpha="0.5" android:background="#AEE5E9FC" android:text="8" /> <Button android:id="@+id/btn9" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_weight="1" android:alpha="0.5" android:background="#AEE5E9FC" android:text="9" /> <Button android:id="@+id/btnSubtract" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_weight="1" android:alpha="0.5" android:background="#AEE5E9FC" android:text="-" /> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" android:orientation="horizontal"> <Button android:id="@+id/btn4" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_weight="1" android:alpha="0.5" android:background="#AEACB7DD" android:text="4" /> <Button android:id="@+id/btn5" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_weight="1" android:background="#AEACB7DD" android:alpha="0.5" android:text="5" /> <Button android:id="@+id/btn6" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_weight="1" android:background="#AEACB7DD" android:alpha="0.5" android:text="6" /> <Button android:id="@+id/btnMultiply" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_weight="1" android:alpha="0.5" android:background="#AEACB7DD" android:text="*" /> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" android:orientation="horizontal"> <Button android:id="@+id/btn1" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_weight="1" android:alpha="0.5" android:background="#AEACB7DD" android:text="1" /> <Button android:id="@+id/btn2" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_weight="1" android:alpha="0.5" android:background="#AEACB7DD" android:text="2" /> <Button android:id="@+id/btn3" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_weight="1" android:alpha="0.5" android:background="#AEACB7DD" android:text="3" /> <Button android:id="@+id/btnDivide" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_weight="1" android:alpha="0.5" android:background="#AEACB7DD" android:text="/" /> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" android:orientation="horizontal"> <Button android:id="@+id/btnSign" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_weight="1" android:alpha="0.5" android:background="#AEACB7DD" android:text="+/-" /> <Button android:id="@+id/btn0" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_weight="1" android:alpha="0.5" android:background="#AEACB7DD" android:text="0" /> <Button android:id="@+id/btnDecimal" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_weight="1" android:alpha="0.5" android:background="#AEACB7DD" android:text="." /> <Button android:id="@+id/btnEquals" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_weight="1" android:alpha="0.5" android:background="#AEACB7DD" android:text="=" /> </LinearLayout> </LinearLayout> 以下是主函数代码: package com.example.qa;import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.TextView; public class MainActivity extends AppCompatActivity { // 声明界面组件 private TextView firstNumView, operatorView, secondNumView, resultView; // 计算器状态变量 private String currentInput = ""; private double firstOperand = 0; private String currentOperator = ""; private boolean resetOnNextInput = false; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // 确保布局文件名匹配 // 初始化TextView组件 firstNumView = findViewById(R.id.firstNumView); operatorView = findViewById(R.id.operatorView); secondNumView = findViewById(R.id.secondNumView); resultView = findViewById(R.id.resultView); // 设置按钮监听器 setupButtonListeners(); } private void setupButtonListeners() { // 数字按钮监听器 setNumberButtonListeners(); // 操作符按钮监听器 setOperatorButtonListeners(); // 功能按钮监听器 setFunctionButtonListeners(); } private void setNumberButtonListeners() { int[] numberButtonIds = { R.id.btn0, R.id.btn1, R.id.btn2, R.id.btn3, R.id.btn4, R.id.btn5, R.id.btn6, R.id.btn7, R.id.btn8, R.id.btn9, R.id.btnDecimal }; for (final int id : numberButtonIds) { findViewById(id).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Button button = (Button) v; String input = button.getText().toString(); if (resetOnNextInput) { clearAll(); resetOnNextInput = false; } // 处理小数点输入 if (input.equals(".")) { if (currentInput.contains(".")) return; // 防止多个小数点 if (currentInput.isEmpty()) currentInput = "0"; } currentInput += input; updateDisplay(); } }); } } private void setOperatorButtonListeners() { int[] operatorButtonIds = { R.id.btnAdd, R.id.btnSubtract, R.id.btnMultiply, R.id.btnDivide }; for (final int id : operatorButtonIds) { findViewById(id).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Button button = (Button) v; String operator = button.getText().toString(); if (!currentInput.isEmpty()) { firstOperand = Double.parseDouble(currentInput); currentOperator = operator; currentInput = ""; resetOnNextInput = false; updateDisplay(); } else if (!currentOperator.isEmpty()) { // 允许更新操作符 currentOperator = operator; updateDisplay(); } } }); } } private void setFunctionButtonListeners() { // 等号按钮 findViewById(R.id.btnEquals).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { calculateResult(); } }); // 清除按钮 findViewById(R.id.btnClear).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { clearAll(); } }); // 正负号按钮 findViewById(R.id.btnSign).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { toggleSign(); } }); // 百分号按钮 findViewById(R.id.btnPercent).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { convertToPercent(); } }); // 平方根按钮 findViewById(R.id.btnBack).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { calculateSquareRoot(); } }); } private void updateDisplay() { firstNumView.setText(currentOperator.isEmpty() ? "" : String.valueOf(firstOperand)); operatorView.setText(currentOperator); secondNumView.setText(currentInput); resultView.setText(""); } private void calculateResult() { if (currentOperator.isEmpty() || currentInput.isEmpty()) return; double secondOperand = Double.parseDouble(currentInput); double result = 0; try { switch (currentOperator) { case "+": result = firstOperand + secondOperand; break; case "-": result = firstOperand - secondOperand; break; case "*": result = firstOperand * secondOperand; break; case "/": if (secondOperand == 0) { resultView.setText("除数不能为0"); resetOnNextInput = true; return; } result = firstOperand / secondOperand; break; } // 处理整数结果显示 String resultStr; if (result == (int) result) { resultStr = String.valueOf((int) result); } else { resultStr = String.format("%.2f", result); } resultView.setText(resultStr); firstOperand = result; currentInput = ""; resetOnNextInput = true; } catch (Exception e) { resultView.setText("错误"); resetOnNextInput = true; } } private void clearAll() { currentInput = ""; firstOperand = 0; currentOperator = ""; resetOnNextInput = false; firstNumView.setText(""); operatorView.setText(""); secondNumView.setText(""); resultView.setText(""); } private void toggleSign() { if (!currentInput.isEmpty()) { double value = Double.parseDouble(currentInput); currentInput = String.valueOf(value * -1); updateDisplay(); } else if (resultView.getText().length() > 0) { double value = Double.parseDouble(resultView.getText().toString()); resultView.setText(String.valueOf(value * -1)); } } private void convertToPercent() { if (!currentInput.isEmpty()) { double value = Double.parseDouble(currentInput); currentInput = String.valueOf(value / 100); updateDisplay(); } else if (resultView.getText().length() > 0) { double value = Double.parseDouble(resultView.getText().toString()); resultView.setText(String.valueOf(value / 100)); } } private void calculateSquareRoot() { if (!currentInput.isEmpty()) { double value = Double.parseDouble(currentInput); if (value < 0) { resultView.setText("无效输入"); return; } currentInput = String.valueOf(Math.sqrt(value)); updateDisplay(); } else if (resultView.getText().length() > 0) { double value = Double.parseDouble(resultView.getText().toString()); if (value < 0) { resultView.setText("无效输入"); return; } resultView.setText(String.valueOf(Math.sqrt(value))); } } } 运行后模拟机显示Unfortunately,qa has stopp。 帮我解决该问题。
最新发布
06-24
### 回答1: 您好,我是AI语言模型,可以帮您解答这个问题。 针对 "Android Studio AVD打不开App" 这个问题,可能的原因有: 1. AVD模拟器没有完全启动,您可以关闭模拟器并重新启动来解决。 2. 模拟器的配置不足,例如内存等配置,您可以尝试调整模拟器配置来解决。 3. 应用程序存在错误或异常,您可以查看Logcat日志来找到具体的错误信息。 4. 您的Android Studio或SDK可能存在错误或异常,您可以尝试重新安装或更新来解决。 希望这些提示可以帮到您。如果您有任何其他问题或疑问,请随时向我提问。 ### 回答2: 当Android Studio AVD无法打开app时,可能会有以下几种原因: 1. 设备配置不足:AVDAndroid Virtual Device)模拟器可能需要较高的计算机性能来运行应用程序。如果您的计算机配置较低,AVD可能无法正常运行应用程序。您可以尝试增加计算机的内存或CPU来解决此问题。 2. AVD设置问题:AVD的设置可能存在问题,导致无法打开app。您可以尝试重新创建AVD,并确保选择了与您的应用程序兼容的正确的Android版本和设备配置。 3. 编译错误:如果您的应用程序包含错误或无法编译的代码,AVD可能无法正常运行。在运行app之前,请确保您的代码没有错误,并且可以成功编译。 4. 更新问题:您的Android Studio或AVD可能需要进行更新,以支持最新的Android版本或修复已知的问题。请确保您的Android Studio和AVD是最新版本。 解决这些问题的方法可能是: 1. 检查您的计算机配置是否满足AVD运行所需的最低要求,并根据需要进行升级。 2. 检查AVD的设置并对其进行调整,以确保与您的应用程序兼容。 3. 检查您的代码并修复任何错误或无法编译的问题。 4. 更新您的Android Studio和AVD到最新版本。 通过仔细检查和调试您的设置和代码,您应该能够解决AVD无法打开app的问题。 ### 回答3: 当Android Studio的AVD无法打开应用程序时,可能有以下几个原因: 1. 虚拟设备配置不正确:可能是因为虚拟设备的配置与应用程序的要求不匹配。请确保虚拟设备的RAM、处理器和存储空间等设置满足应用程序的要求。 2. 安装的应用程序有问题:如果应用程序在其他设备上可以正常运行,但无法在AVD上打开,可能是应用程序本身有问题。尝试重新安装应用程序或使用其他应用程序测试AVD。 3. 代码错误:如果应用程序中存在代码错误,可能会导致AVD无法正常打开。检查应用程序的日志和错误消息,以确定是否存在代码错误,并进行修复。 4. AVD配置错误:可能是因为AVD本身的配置有问题。尝试使用其他AVD或重新创建一个新的AVD来测试应用程序。 5. 硬件加速问题:某些情况下,硬件加速可能会导致AVD无法正常工作。尝试禁用硬件加速,可以在AVD Manager中选择虚拟设备,然后在右侧的“选项”下拉菜单中选择“编辑”,在“编辑AVD”对话框中的“高级设置”部分禁用硬件加速选项。 如果以上解决方法都无效,建议更新Android Studio到最新版本,或将问题提交给Android Studio的开发者社区寻求帮助。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值