Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot create AudioRecord #79

Open
SEAN-JOU opened this issue Jul 31, 2018 · 5 comments
Open

Cannot create AudioRecord #79

SEAN-JOU opened this issue Jul 31, 2018 · 5 comments

Comments

@SEAN-JOU
Copy link

        java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.androidthings.assistant/com.example.androidthings.assistant.AssistantActivity}: java.lang.UnsupportedOperationException: Cannot create AudioRecord
                                                                                     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2778)
                                                                                     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
                                                                                     at android.app.ActivityThread.-wrap11(Unknown Source:0)
                                                                                     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
                                                                                     at android.os.Handler.dispatchMessage(Handler.java:106)
                                                                                     at android.os.Looper.loop(Looper.java:164)
                                                                                     at android.app.ActivityThread.main(ActivityThread.java:6494)
                                                                                     at java.lang.reflect.Method.invoke(Native Method)
                                                                                     at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
                                                                                     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
                                                                                  Caused by: java.lang.UnsupportedOperationException: Cannot create AudioRecord
                                                                                     at android.media.AudioRecord$Builder.build(AudioRecord.java:626)
                                                                                     at com.example.androidthings.assistant.EmbeddedAssistant$Builder.build(EmbeddedAssistant.java:706)
                                                                                     at com.example.androidthings.assistant.AssistantActivity.onCreate(AssistantActivity.java:313)
@Fleker
Copy link
Collaborator

Fleker commented Jul 31, 2018

Have you enabled the permission to record audio?

@SEAN-JOU
Copy link
Author

SEAN-JOU commented Aug 1, 2018

AndroidManifest.xml
< uses-permission android:name="android.permission.RECORD_AUDIO" />
AssistantActivity.java onCreate()
ActivityCompat.requestPermissions(this, new String[]{
"com.google.android.things.permission.RECORD_AUDIO",
"com.google.android.things.permission.USE_PERIPHERAL_IO"}, 0);

yes i have . it still show "Cannot create AudioRecord......"

@Fleker
Copy link
Collaborator

Fleker commented Aug 1, 2018

Are there any logs related to this which may be available a little before the stacktrace? (You may need to change the filter from Show only application to No filter)

@SEAN-JOU
Copy link
Author

SEAN-JOU commented Aug 8, 2018

1624-1624/com.example.androidthings.assistant E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.androidthings.assistant, PID: 1624
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.androidthings.assistant/com.example.androidthings.assistant.AssistantActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.media.AudioRecord.setPreferredDevice(android.media.AudioDeviceInfo)' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2778)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.media.AudioRecord.setPreferredDevice(android.media.AudioDeviceInfo)' on a null object reference
at com.example.androidthings.assistant.EmbeddedAssistant$Builder.build(EmbeddedAssistant.java:704)
at com.example.androidthings.assistant.AssistantActivity.onCreate(AssistantActivity.java:313)
at android.app.Activity.performCreate(Activity.java:7010)
at android.app.Activity.performCreate(Activity.java:7001)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2731)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856) 
at android.app.ActivityThread.-wrap11(Unknown Source:0) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589) 
at android.os.Handler.dispatchMessage(Handler.java:106) 
at android.os.Looper.loop(Looper.java:164) 
at android.app.ActivityThread.main(ActivityThread.java:6494) 

@Fleker
Copy link
Collaborator

Fleker commented Aug 8, 2018

Do you see any other errors in the logs, like failed to find I2S audio input device, using default or error configuring peripherals:?

It looks like the flag USE_VOICEHAT_I2S_DAC is true. Are you using the VoiceHat? What Android Things device are you using?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants