Flutter 创建项目中遇到的问题

Flutter 架包版本:2.10.4

Flutter SDK 版本列表 | Flutter 中文文档 | Flutter 中文开发者网站

系统环境:macOS 12.3.1

创建Flutter 项目可参考

Flutter学习之旅~创建项目_leftstrange的博客-CSDN博客

程序搭建中遇到的问题

1. 警告:Warning: Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01

解决方式:

修改:gradle-wrapper.properties文件

文件路径:android/gradle/wrapper/gradle-wrapper.properties

修改内:distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip

修改:build.gradle

文件路径:android/build.gradle

修改内容:classpath 'com.android.tools.build:gradle:7.0.4'

 2.Flutter 编译运行很慢

解决方式:添加国内镜像

修改文件:build.gradle和flutter.gradle

文件路径:android/build.gradle

文件路径:flutter架包中“flutter/packages/flutter_tools/gradle/flutter.gradle”

将:
        google()
        mavenCentral()  

替换成为:      

        maven {
            allowInsecureProtocol = true
            url 'https://maven.aliyun.com/repository/google'
        }
        maven {
            allowInsecureProtocol = true
            url 'https://maven.aliyun.com/repository/jcenter'
        }
        maven {
            allowInsecureProtocol = true
            url 'http://maven.aliyun.com/nexus/content/groups/public'
        }

3. 报错:Using insecure protocols with repositories, without explicit opt-in, is unsupported. Switch Maven repository 'maven3(http://maven.aliyun.com/nexus/content/groups/public)' to redirect to a secure protocol (like HTTPS) or allow insecure protocols. See https://docs.gradle.org/7.0.2/dsl/org.gradle.api.artifacts.repositories.UrlArtifactRepository.html#org.gradle.api.artifacts.repositories.UrlArtifactRepository:allowInsecureProtocol for more details.

根据描述“maven”是一个不安全的协议,所以问题就简单了,怎样让他安全化;

解决方式:

 在maven内添加代码: allowInsecureProtocol = true

        maven {
            allowInsecureProtocol = true
            ...
        }

4. MACOS中build是遇到的报错

Launching lib/main.dart on iPhone 15 Pro Max in debug mode...
main.dart:1
Xcode build done.                                            6.7s
Failed to build iOS app
Error output from Xcode build:
↳
    --- xcodebuild: WARNING: Using the first of multiple matching destinations:
    { platform:iOS Simulator, id:dvtdevice-DVTiOSDeviceSimulatorPlaceholder-iphonesimulator:placeholder, name:Any iOS Simulator Device }
    { platform:iOS Simulator, id:B2D29A43-6B9B-4826-B609-4DC43196BB26, OS:17.4, name:iPad (10th generation) }
    { platform:iOS Simulator, id:ADD38D01-AE6C-43BE-AF94-E174DDE117D9, OS:17.4, name:iPad Air (5th generation) }
    { platform:iOS Simulator, id:926639C9-D5FB-4E81-81D4-2709BB10E1F2, OS:17.4, name:iPad Pro (11-inch) (4th generation) }
    { platform:iOS Simulator, id:DD926384-7485-4570-A9CB-89F124A5BBE5, OS:17.4, name:iPad Pro (12.9-inch) (6th generation) }
    { platform:iOS Simulator, id:0580A9A6-EF2C-4077-BE22-87FF387DBD0E, OS:17.4, name:iPad mini (6th generation) }
    { platform:iOS Simulator, id:380F3A77-6DFF-4437-8CB4-C47283221CAC, OS:17.4, name:iPhone 15 }
    { platform:iOS Simulator, id:CBE2630A-FA7B-4191-9D68-690CCA3AD3E3, OS:17.4, name:iPhone 15 Plus }
    { platform:iOS Simulator, id:335C5FB4-8956-4EFA-938F-48F79CA457AE, OS:17.4, name:iPhone 15 Pro }
    { platform:iOS Simulator, id:40667219-F3FF-437B-811C-68A3E2346276, OS:17.4, name:iPhone 15 Pro Max }
    { platform:iOS Simulator, id:1197B7B6-1B36-4BFD-8FA6-3B263EE2F5D7, OS:17.4, name:iPhone SE (3rd generation) }
    { platform:iOS Simulator, id:B2D29A43-6B9B-4826-B609-4DC43196BB26, OS:17.4, name:iPad (10th generation) }
    { platform:iOS Simulator, id:ADD38D01-AE6C-43BE-AF94-E174DDE117D9, OS:17.4, name:iPad Air (5th generation) }
    { platform:iOS Simulator, id:926639C9-D5FB-4E81-81D4-2709BB10E1F2, OS:17.4, name:iPad Pro (11-inch) (4th generation) }
    { platform:iOS Simulator, id:DD926384-7485-4570-A9CB-89F124A5BBE5, OS:17.4, name:iPad Pro (12.9-inch) (6th generation) }
    { platform:iOS Simulator, id:0580A9A6-EF2C-4077-BE22-87FF387DBD0E, OS:17.4, name:iPad mini (6th generation) }
    { platform:iOS Simulator, id:380F3A77-6DFF-4437-8CB4-C47283221CAC, OS:17.4, name:iPhone 15 }
    { platform:iOS Simulator, id:CBE2630A-FA7B-4191-9D68-690CCA3AD3E3, OS:17.4, name:iPhone 15 Plus }
    { platform:iOS Simulator, id:335C5FB4-8956-4EFA-938F-48F79CA457AE, OS:17.4, name:iPhone 15 Pro }
    { platform:iOS Simulator, id:40667219-F3FF-437B-811C-68A3E2346276, OS:17.4, name:iPhone 15 Pro Max }
    { platform:iOS Simulator, id:1197B7B6-1B36-4BFD-8FA6-3B263EE2F5D7, OS:17.4, name:iPhone SE (3rd generation) }
    { platform:iOS, id:dvtdevice-DVTiPhonePlaceholder-iphoneos:placeholder, name:Any iOS Device }
    ** BUILD FAILED **
Xcode's output:
↳
    clang: error: SDK does not contain 'libarclite' at the path '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/arc/libarclite_iphonesimulator.a'; try increasing the minimum deployment target
    /Users/shenef/Desktop/NasCode/vRoot/Case/Case019-ZgMetroTmp/ZgMetroTmpStandardEdition_2_0_5/ZgMetroTmpApp/ios/Pods/Pods.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 12.0 to 17.4.99. (in target 'install_plugin' from project 'Pods')
    /Users/shenef/Desktop/NasCode/vRoot/Case/Case019-ZgMetroTmp/ZgMetroTmpStandardEdition_2_0_5/ZgMetroTmpApp/ios/Pods/Pods.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 12.0 to 17.4.99. (in target 'scan' from project 'Pods')
    /Users/shenef/Desktop/NasCode/vRoot/Case/Case019-ZgMetroTmp/ZgMetroTmpStandardEdition_2_0_5/ZgMetroTmpApp/ios/Pods/Pods.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 12.0 to 17.4.99. (in target 'background_fetch' from project 'Pods')
    /Users/shenef/Desktop/NasCode/vRoot/Case/Case019-ZgMetroTmp/ZgMetroTmpStandardEdition_2_0_5/ZgMetroTmpApp/ios/Pods/Pods.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 12.0 to 17.4.99. (in target 'flutter_full_pdf_viewer' from project 'Pods')
    /Users/shenef/Desktop/NasCode/vRoot/Case/Case019-ZgMetroTmp/ZgMetroTmpStandardEdition_2_0_5/ZgMetroTmpApp/ios/Pods/Pods.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 12.0 to 17.4.99. (in target 'flutter_app_badger' from project 'Pods')
    warning: Run script build phase 'Run Script' will be run during every build because it does not specify any outputs. To address this warning, either add output dependencies to the script phase, or configure it to run in every build by unchecking "Based on dependency analysis" in the script phase. (in target 'Runner' from project 'Runner')
    warning: Run script build phase 'Thin Binary' will be run during every build because it does not specify any outputs. To address this warning, either add output dependencies to the script phase, or configure it to run in every build by unchecking "Based on dependency analysis" in the script phase. (in target 'Runner' from project 'Runner')
    /Users/shenef/Desktop/NasCode/vRoot/Case/Case019-ZgMetroTmp/ZgMetroTmpStandardEdition_2_0_5/ZgMetroTmpApp/ios/Pods/Pods.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 12.0 to 17.4.99. (in target 'url_launcher' from project 'Pods')
    /Users/shenef/Desktop/NasCode/vRoot/Case/Case019-ZgMetroTmp/ZgMetroTmpStandardEdition_2_0_5/ZgMetroTmpApp/ios/Pods/Pods.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 12.0 to 17.4.99. (in target 'image_picker' from project 'Pods')
    /Users/shenef/Desktop/NasCode/vRoot/Case/Case019-ZgMetroTmp/ZgMetroTmpStandardEdition_2_0_5/ZgMetroTmpApp/ios/Pods/Pods.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 12.0 to 17.4.99. (in target 'shared_preferences' from project 'Pods')
    /Users/shenef/Desktop/NasCode/vRoot/Case/Case019-ZgMetroTmp/ZgMetroTmpStandardEdition_2_0_5/ZgMetroTmpApp/ios/Pods/Pods.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 12.0 to 17.4.99. (in target 'JPush' from project 'Pods')
    /Users/shenef/Desktop/NasCode/vRoot/Case/Case019-ZgMetroTmp/ZgMetroTmpStandardEdition_2_0_5/ZgMetroTmpApp/ios/Pods/Pods.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 12.0 to 17.4.99. (in target 'JCore' from project 'Pods')
    /Users/shenef/Desktop/NasCode/vRoot/Case/Case019-ZgMetroTmp/ZgMetroTmpStandardEdition_2_0_5/ZgMetroTmpApp/ios/Pods/Pods.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 12.0 to 17.4.99. (in target 'permission_handler' from project 'Pods')
    /Users/shenef/Desktop/NasCode/vRoot/Case/Case019-ZgMetroTmp/ZgMetroTmpStandardEdition_2_0_5/ZgMetroTmpApp/ios/Pods/Pods.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 12.0 to 17.4.99. (in target 'Flutter' from project 'Pods')
    /Users/shenef/Desktop/NasCode/vRoot/Case/Case019-ZgMetroTmp/ZgMetroTmpStandardEdition_2_0_5/ZgMetroTmpApp/ios/Pods/Pods.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 12.0 to 17.4.99. (in target 'path_provider' from project 'Pods')
    /Users/shenef/Desktop/NasCode/vRoot/Case/Case019-ZgMetroTmp/ZgMetroTmpStandardEdition_2_0_5/ZgMetroTmpApp/ios/Pods/Pods.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 12.0 to 17.4.99. (in target 'jpush_flutter' from project 'Pods')
    /Users/shenef/Desktop/NasCode/vRoot/Case/Case019-ZgMetroTmp/ZgMetroTmpStandardEdition_2_0_5/ZgMetroTmpApp/ios/Pods/Pods.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 12.0 to 17.4.99. (in target 'device_info' from project 'Pods')
    /Users/shenef/Desktop/NasCode/vRoot/Case/Case019-ZgMetroTmp/ZgMetroTmpStandardEdition_2_0_5/ZgMetroTmpApp/ios/Pods/Pods.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 12.0 to 17.4.99. (in target 'geolocator' from project 'Pods')
    /Users/shenef/Desktop/NasCode/vRoot/Case/Case019-ZgMetroTmp/ZgMetroTmpStandardEdition_2_0_5/ZgMetroTmpApp/ios/Pods/Pods.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 12.0 to 17.4.99. (in target 'uni_links' from project 'Pods')
    /Users/shenef/Desktop/NasCode/vRoot/Case/Case019-ZgMetroTmp/ZgMetroTmpStandardEdition_2_0_5/ZgMetroTmpApp/ios/Pods/Pods.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 9.0, but the range of supported deployment target versions is 12.0 to 17.4.99. (in target 'sqflite' from project 'Pods')
    /Users/shenef/Desktop/NasCode/vRoot/Case/Case019-ZgMetroTmp/ZgMetroTmpStandardEdition_2_0_5/ZgMetroTmpApp/ios/Pods/Pods.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 12.0 to 17.4.99. (in target 'package_info' from project 'Pods')
Could not build the application for the simulator.

解决方案:

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib

在路径下面增加arc文件夹

arc文件夹中增加以下文件

git地址:GitHub - zhaiAlan/Libarclite-Files

感谢提供文件的大佬

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值