我从颤振包中导入了以下声音包。
音频播放器:^ 0.12.1
抛出错误,说我需要安装一些东西。根据错误消息,我运行了以下命令。
酿造可可粉
吊舱吊舱设置
设置成功完成。
此后,当我尝试运行我的应用程序时,它开始引发错误。该应用程序不过是带有空MaterialApp()小部件的无状态小部件。在执行上述安装之前,此方法工作正常。
我尝试删除audioplayers依赖性,但错误仍然存在。尝试重建并重新启动我的IDE并没有帮助。请指教出什么问题了。我不明白为什么即使删除依赖项后错误仍然存在。如果这很重要,我正在使用Mac。请指教。谢谢。
错误日志:
Launching lib/main.dart on iPhone X in debug mode...
Running pod install...
Running Xcode build...
Xcode build done. 1.9s
Failed to build iOS app
Error output from Xcode build:
↳
** BUILD FAILED **
Xcode's output:
↳
=== BUILD TARGET path_provider OF PROJECT Pods WITH CONFIGURATION Debug ===
/Users/myusername/.pub-cache/hosted/pub.dartlang.org/audioplayers-0.12.1/ios/Classes/AudioplayersPlugin.m:232:5: error: use of undeclared identifier 'AVAudioSessionCategory'; did you mean 'AVAudioSessionCategoryRecord'?
AVAudioSessionCategory category;
^~~~~~~~~~~~~~~~~~~~~~
AVAudioSessionCategoryRecord
In module 'AVFoundation' imported from /Users/myusername/.pub-cache/hosted/pub.dartlang.org/audioplayers-0.12.1/ios/Classes/AudioplayersPlugin.m:4:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.2.sdk/System/Library/Frameworks/AVFoundation.framework/Frameworks/AVFAudio.framework/Headers/AVAudioSession.h:642:28: note: 'AVAudioSessionCategoryRecord' declared here
AVF_EXPORT NSString *const AVAudioSessionCategoryRecord;
^
/Users/myusername/.pub-cache/hosted/pub.dartlang.org/audioplayers-0.12.1/ios/Classes/AudioplayersPlugin.m:232:27: error: expected ';' after expression
AVAudioSessionCategory category;
^
;
/Users/myusername/.pub-cache/hosted/pub.dartlang.org/audioplayers-0.12.1/ios/Classes/AudioplayersPlugin.m:232:28: error: use of undeclared identifier 'category'
AVAudioSessionCategory category;
^
/Users/myusername/.pub-cache/hosted/pub.dartlang.org/audioplayers-0.12.1/ios/Classes/AudioplayersPlugin.m:234:9: error: use of undeclared identifier 'category'
category = AVAudioSessionCategoryAmbient;
^
/Users/myusername/.pub-cache/hosted/pub.dartlang.org/audioplayers-0.12.1/ios/Classes/AudioplayersPlugin.m:236:9: error: use of undeclared identifier 'category'
category = AVAudioSessionCategoryPlayback;
^
/Users/myusername/.pub-cache/hosted/pub.dartlang.org/audioplayers-0.12.1/ios/Classes/AudioplayersPlugin.m:239:34: error: use of undeclared identifier 'category'
setCategory: category
^
/Users/myusername/.pub-cache/hosted/pub.dartlang.org/audioplayers-0.12.1/ios/Classes/AudioplayersPlugin.m:232:5: warning: expression result unused [-Wunused-value]
AVAudioSessionCategory category;
^~~~~~~~~~~~~~~~~~~~~~
1 warning and 6 errors generated.
Could not build the application for the simulator.
Error launching application on iPhone X.
答案 0 :(得分:0)
我有一个解决方案,尽管我承认这不是最佳解决方案。
我的猜测是,该错误与Xcode试图将其构建为通用应用而不是iOS应用有关,尽管我对Xcode的了解还不足以验证这一点(我主要是一名与Flutter合作的Android开发人员)。 AVAudioSessionCategory不适用于MacOS,仅适用于iOS。
构建后,我遇到了与上述相同的错误。在232行的AudioplayersPlugin.m中,您将看到以下内容:
mysql.connector.__version__
替换为:
AVAudioSessionCategory category;
if (respectSilence) {
category = AVAudioSessionCategoryAmbient;
} else {
category = AVAudioSessionCategoryPlayback;
}
BOOL success = [[AVAudioSession sharedInstance]
setCategory: category
error:&error];
您的应用应立即在iOS上运行。