- Creating flutter project 卡住:
在Android Studio安装目录下的文件夹,找到 idea.properties 文件,在最后加上一句:
disable.android.first.run=true
保存,重启AS,新建flutter项目,就可以顺利的过去了
Cannot find "xcodebuild". Xcode 11.0 or greater is required to develop for iOS. Could not build the precompiled application for the device.
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
如果路径不对,可以找到Xcode,拉去路径
Your Xcode version may be too old for your iOS version, The service is invalid. AMDeviceSecureSta...
报错的元凶是flutter/bin/cache/artifacts/ios-deploy/ios-deploy,不知道ios-deploy可自行百度,查看当前版本为1.10,下载最新版本,使用xcode编译后,将 product 文件夹内的 ios-deploy 文件替换掉上述目录内的文件即可
error: The linked and embedded framework 'App.framework' is missing one or more architectures required by this target: armv7. (in target 'Runner' from project 'Runner')
- 在项目根目录下:
lutter clean
- 删除ios/Flutter/App.framework:
rm -rf ios/Flutter/App.framework
- flutter 升级:在终端里使用
flutter upgrade
或flutter upgrade --force
flutter upgrade
时出现如下错误error: RPC failed; curl 18 transfer closed with outstanding read data remaining
缓存区溢出curl的postBuffer的默认值太小,需要增加缓存
使用git命令增大缓存(单位是b,524288000B也就500M左右)git config --global http.postBuffer 524288000
使用git config --list查看是否生效
-
应用一直
Installing and launching...
,多数情况是需要对Flutter 进行升级 -
删除 Derived data 下的文件,在“前往文件夹”中输入
~/Library/Developer/Xcode/DerivedData
删除文件夹下文件 -
error: Building for iOS, but the linked and embedded framework 'App.framework' was built for iOS Simulator. (in target 'Runner' from project 'Runner')
- 在项目根目录下
flutter clean
- 然后删除ios/Flutter/App.framework:
rm -rf ios/Flutter/App.framework
- Android 原生工程引入 flutter_module后报错
caused by org.gradle.api.internal.plugins.pluginapplicationexception failed to apply plugin
找到settings.gradle,将FAIL_ON_PROJECT_REPOS修改为PREFER_PROJECT,保存重新Build。
- Android 原生工程引入Flutter_moudule
- 在原生工程的settings.gradle中添加
include ':flutter_test_module'
setBinding(new Binding([gradle: this]))
evaluate(new File(settingsDir.parentFile, 'flutter_test_module/.android/include_flutter.groovy'))
2.在原生目录
app->build.gradle->dependencies
添加implementation project(path: ':flutter')
- 在iOS原生工程中引入Flutter:在
podfile
文件中添加如下代码:
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
flutter_application_path = '../flutter_test_module'
load File.join(flutter_application_path, '.ios', 'Flutter', 'podhelper.rb')
target 'flutter_test_ios' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!
install_all_flutter_pods(flutter_application_path)
# Pods for flutter_test_ios
end
后执行
pod install
再通过命令生成framework
cd /Users/xxx/Desktop/iOS\ Flutter/my_flutter
flutter build ios-framework --output=./Flutter/
framework生成之后然后将
App.framework
和Flutter.framework
拖入Build Settings > Build Phases > Link Binary With Libraries:
,此时xcode左侧的Frameworks文件夹下会多出 App 和 Flutter两个framework,此时可编译
若报错
framework not found FlutterPluginRegistrant
,我进行了一下pod update
就好了
pod init
报错Traceback (most recent call last):
:
sudo gem install xcodeproj
can resolve it.