Muh*_*tar 4 webrtc flutter flutter-dependencies apple-m1
我正在尝试在我的 m1 MacBook Air 上构建一个 webrtc flutter 应用程序。但我在 android 和 ios 上遇到了不同的问题。最新的 ^0.8.2 在两者上都有错误,然后 ^0.7.0+hotfix.1 演示演示仅适用于 Android。
\n在 iOS 部分,“Libyuv”的部署目标设置为 8.0,但最小部署目标为 9.0。我将部署目标设置为 10 以上,但它仍然发生。
\n/Users/alperenbaskaya/Desktop/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_webrtc-0.7.1/ios/Classes/FlutterWebRTCPlugin.h:8:9: fatal error: \'WebRTC/WebRTC.h\' file not found\n #import <WebRTC/WebRTC.h>\n ^~~~~~~~~~~~~~~~~\n 1 error generated.\n/Users/alperenbaskaya/Desktop/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_webrtc-0.7.1/ios/Classes/FlutterRTCMediaStream.m:3:9: fatal error: \'WebRTC/WebRTC.h\' file not found\n #import <WebRTC/WebRTC.h>\n ^~~~~~~~~~~~~~~~~\n 1 error generated.\nIn file included from /Users/alperenbaskaya/Desktop/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_webrtc-0.7.1/ios/Classes/FlutterRTCFrameCapturer.m:8:\n/Users/alperenbaskaya/Desktop/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_webrtc-0.7.1/ios/Classes/FlutterRTCFrameCapturer.h:6:9: fatal error: \'WebRTC/WebRTC.h\' file not found\n #import <WebRTC/WebRTC.h>\n ^~~~~~~~~~~~~~~~~\n 1 error generated.\nIn file included from /Users/alperenbaskaya/Desktop/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_webrtc-0.7.1/ios/Classes/FlutterRTCDataChannel.m:2:\nIn file included from /Users/alperenbaskaya/Desktop/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_webrtc-0.7.1/ios/Classes/FlutterRTCDataChannel.h:1:\n/Users/alperenbaskaya/Desktop/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_webrtc-0.7.1/ios/Classes/FlutterWebRTCPlugin.h:8:9: fatal error: \'WebRTC/WebRTC.h\' file not found\n #import <WebRTC/WebRTC.h>\n ^~~~~~~~~~~~~~~~~\n 1 error generated.\n note: Using new build system\n note: Building targets in parallel\n note: Planning build\n note: Analyzing workspace\n note: Constructing build description\n note: Build preparation complete\n /Users/alperenbaskaya/AndroidStudioProjects/flutter-webrtc-demo/ios/Pods/Pods.xcodeproj: warning: The iOS Simulator deployment target \'IPHONEOS_DEPLOYMENT_TARGET\' is set to 4.3, but the range of supported deployment target versions is 9.0 to 14.5.99. (in target \'Libyuv\' from project \'Pods\')\nCould not build the application for the simulator.\nError launching application on iPhone 8 Plus.\nRun Code Online (Sandbox Code Playgroud)\n经过解决方法后,我更新了 libyuv 部署目标,但现在出现以下 ios 错误;
\n objc[66512]: Class AMSupportURLConnectionDelegate is implemented in both /usr/lib/libauthinstall.dylib (0x20d426c10) and /System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x113d3c2b8). One of the two will be used. Which one is undefined.\n objc[66512]: Class AMSupportURLSession is implemented in both /usr/lib/libauthinstall.dylib (0x20d426c60) and /System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x113d3c308). One of the two will be used. Which one is undefined.\n ** BUILD FAILED **\nXcode\'s output:\n\xe2\x86\xb3\n warning: [CP] Unable to find matching .xcframework slice in \'ios-arm64_x86_64-simulator ios-arm64_armv7\' for the current build architectures (arm64 x86_64 i386).\nIn file included from /Users/alperenbaskaya/Desktop/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_webrtc-0.8.2/ios/Classes/FlutterRTCPeerConnection.m:2:\n/Users/alperenbaskaya/Desktop/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_webrtc-0.8.2/ios/Classes/FlutterWebRTCPlugin.h:8:9: fatal error: \'WebRTC/WebRTC.h\' file not found\n #import <WebRTC/WebRTC.h>\n ^~~~~~~~~~~~~~~~~\n 1 error generated.\n note: Using new build system\n note: Building targets in parallel\n note: Planning build\n note: Analyzing workspace\n note: Constructing build description\n note: Build preparation complete\nCould not build the application for the simulator.\nError launching application on iPhone 8 Plus.\nRun Code Online (Sandbox Code Playgroud)\n在android方面我得到了关注;
\nExecution failed for task \':flutter_webrtc:compileDebugJavaWithJavac\'.\nRun Code Online (Sandbox Code Playgroud)\n
对于版本 ^0.8.2,以下解决方案对我有用。
iOS系统
在ios/Podfile中将以下内容添加到文件末尾。
post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
target.build_configurations.each do |build_configuration|
build_configuration.build_settings['EXCLUDED_ARCHS[sdk=iphonesimulator*]'] = 'arm64 i386'
end
end
end
Run Code Online (Sandbox Code Playgroud)
然后清理您的项目并按照 santoshakil 提到的santoshakilsanswer执行以下步骤;(如果不遵循链接中提到的所有步骤,这些步骤对我有用)
flutter clean && flutter pub get
cd ios
arch -x86_64 pod update
arch -x86_64 pod install
then at the top of your Pod file, paste this line platform :ios, '10.0'
right click on ios folder and open in xcode and then set all deployment target to 10
Run Code Online (Sandbox Code Playgroud)
Android 你的 android/app/build.gradle 如下所示webrtcflutterdemo
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}
apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion 28
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.cloudwebrtc.flutterwebrtcdemo"
minSdkVersion 21
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
useProguard true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/proguard/androidx-annotations.pro'
}
}
flutter {
source '../..'
}
dependencies {
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
Run Code Online (Sandbox Code Playgroud)
android/app/AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.cloudwebrtc.flutterwebrtcdemo">
<!-- The INTERNET permission is required for development. Specifically,
flutter needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
-->
<uses-permission android:name="android.permission.INTERNET"/>
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<!-- io.flutter.app.FlutterApplication is an android.app.Application that
calls FlutterMain.startInitialization(this); in its onCreate method.
In most cases you can leave this as-is, but you if you want to provide
additional functionality it is fine to subclass or reimplement
FlutterApplication and put your custom class here. -->
<application
android:label="flutter_webrtc_demo"
android:icon="@mipmap/ic_launcher">
<meta-data
Run Code Online (Sandbox Code Playgroud)
编辑 对于Android端,我无法构建compilesdk和targetsdk 31。临时解决方案是将compilesdk降级到30。它与您的mac设备上的jdk版本有关。
| 归档时间: |
|
| 查看次数: |
2922 次 |
| 最近记录: |