我一直在android studio中开发一个简单的应用程序,但是当我试图运行它时,我的应用程序一直在崩溃。 stacktrace:
03-29 23:32:34.720 2130-2206/com.google.android.googlequicksearchbox:search
E/AudioRecord: Could not get audio input for session 4801, record source
1999, sample rate 16000, format 0x1, channel mask 0x10, flags 0
03-29 23:32:34.720 2130-2206/com.google.android.googlequicksearchbox:search
E/AudioRecord-JNI: Error creating AudioRecord instance: initialization check
failed with status -22.
03-29 23:32:34.720 2130-2206/com.google.android.googlequicksearchbox:search
E/android.media.AudioRecord: Error code -20 when initializing native
AudioRecord object.
03-29 23:32:34.721 2130-2206/com.google.android.googlequicksearchbox:search
E/ActivityThread: Failed to find provider info for
com.google.android.apps.gsa.testing.ui.audio.recorded
: onFatalError, processing error from engine(4)
com.google.android.apps.gsa.shared.speech.a.g: Error reading from input stream
at com.google.android.apps.gsa.staticplugins.recognizer.i.a.a(SourceFile:342)
at com.google.android.apps.gsa.staticplugins.recognizer.i.a$1.run(SourceFile:1367)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:428)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at com.google.android.apps.gsa.shared.util.concurrent.a.ak.run(SourceFile:66)
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)
at com.google.android.apps.gsa.shared.util.concurrent.a.ad$1.run(SourceFile:85)
Caused by: com.google.android.apps.gsa.shared.exception.GsaIOException: Error code: 393238 | Buffer overflow, no available space.
at com.google.android.apps.gsa.speech.audio.Tee.g(SourceFile:2531)
at com.google.android.apps.gsa.speech.audio.ap.read(SourceFile:555)
at java.io.InputStream.read(InputStream.java:101)
at com.google.android.apps.gsa.speech.audio.al.run(SourceFile:362)
at com.google.android.apps.gsa.speech.audio.ak$1.run(SourceFile:471)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:428)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at com.google.android.apps.gsa.shared.util.concurrent.a.ak.run(SourceFile:66)
at com.google.android.apps.gsa.shared.util.concurrent.a.ax.run(SourceFile:139)
at com.google.android.apps.gsa.shared.util.concurrent.a.ax.run(SourceFile:139)
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)
at com.google.android.apps.gsa.shared.util.concurrent.a.ad$1.run(SourceFile:85)

我不明白为什么会发生这种情况,我从不尝试在我的应用中使用麦克风或任何相关音频。
这是我的AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.nick.project2" >
<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/AppTheme" >
<activity android:name=".MainActivity" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
调试我的MainActivity.java时,这是崩溃的代码块:
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
getFragmentManager().beginTransaction().add(R.id.professorContainer, myTeacher).commit();
//Check to see if we should get the layout for a phone or a tablet
if(findViewById(R.id.professorContainer) != null){
//
getFragmentManager().beginTransaction().add(R.id.professorContainer, myTeacher);
}
}
它在onCreate方法的第三行崩溃,&#34; getFragmentManager()....&#34;
答案 0 :(得分:0)
我猜你的布局中可能有一些quicksearch小部件。 Quicksearch使用需要音频记录权限的Google语音识别API。添加该权限。
<uses-permission android:name="android.permission.RECORD_AUDIO" />