Flutter环境坑 --持续更新

配置

基本配置成功是这样的。


image.png

可以看到其实需四部分东西:
1、二进制,我们使用稳定版1.22.x。具体参照 https://flutter.cn/docs/get-started/install/macos
2.工具链,android和iOS两个系统的工具链
3.IDE Android Studio及flutter/dart插件
4.调试模拟器

Mac中最常见的问题就是和android相关的

一、flutter和dart的插件找不到,明明已经下载了,就是报错

image.png

这是因为Android Studio (4.1) 的插件位置换成了
~/Library/Application\ Support/Google/AndroidStudio4.1/plugins,而老版本的位置为~/Library/Application\ Support/AndroidStudio4.1

需要执行一个软链

ln -s ~/Library/Application\ Support/Google/AndroidStudio4.1/plugins ~/Library/Application\ Support/AndroidStudio4.1

二、android sdk的版本和platform tool的版本提示错误

Flutter requires Android SDK 29 and the Android BuildTools 28.0.3 To update the Android SDK visit

image.png

这个有两个可能的原因:

1、确实没有安装android sdk和platform-tool的包

切记,要勾选show package details选项框,才会显示出所有版本号。

image.png

2、PATH没有配置对

android studio下载的路径是Android SDK location对应的路径,而flutter doctor 检测的路径是环境变量PATH,此二者务必对应上!

image.png

image.png

这是flutter doctor遇到的两个主要坑

三、运行问题

Android问题

1.android跑不起来,Gradle threw an error while trying to update itself.
Launching lib\main.dart on Android SDK built for x86 in debug mode...
Running Gradle task 'assembleDebug'...
Exception in thread "main" java.util.zip.ZipException: error in opening zip file
    at java.util.zip.ZipFile.open(Native Method)
    at java.util.zip.ZipFile.<init>(ZipFile.java:225)
    at java.util.zip.ZipFile.<init>(ZipFile.java:155)
    at java.util.zip.ZipFile.<init>(ZipFile.java:169)
    at org.gradle.wrapper.Install.unzip(Install.java:214)
    at org.gradle.wrapper.Install.access$600(Install.java:27)
    at org.gradle.wrapper.Install$1.call(Install.java:74)
    at org.gradle.wrapper.Install$1.call(Install.java:48)
    at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:65)
    at org.gradle.wrapper.Install.createDist(Install.java:48)
    at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:128)
    at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61)
[!] Gradle threw an error while trying to update itself. Retrying the update...

这个的原因是gradle的版本问题,需要把系统中的gradle版本删掉,然后run的时候自动下载一个就可以了
/Users/用户名/.gradle/wrapper/dists/gradle-5.6.2-all
或者也可以下载文件放到这个目录中,把之前的替代了
https://downloads.gradle-dn.com/distributions/gradle-5.6.2-all.zip

2、安卓跑不起来, io.flutter问题
Execution failed for task ':app:checkDebugAarMetadata'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
   > Could not resolve io.flutter:arm64_v8a_debug:1.0.0-920a33a0fc3a1d9913d889a77593161e175f1863.
     Required by:
         project :app
      > Could not resolve io.flutter:arm64_v8a_debug:1.0.0-920a33a0fc3a1d9913d889a77593161e175f1863.
         > Could not get resource 'https://dl.google.com/dl/android/maven2/io/flutter/arm64_v8a_debug/1.0.0-920a33a0fc3a1d9913d889a77593161e175f1863/arm64_v8a_debug-1.0.0-920a33a0fc3a1d9913d889a77593161e175f1863.pom'.
            > Could not GET 'https://dl.google.com/dl/android/maven2/io/flutter/arm64_v8a_debug/1.0.0-920a33a0fc3a1d9913d889a77593161e175f1863/arm64_v8a_debug-1.0.0-920a33a0fc3a1d9913d889a77593161e175f1863.pom'.
               > Connect to dl.google.com:443 [dl.google.com/203.208.50.97] failed: Read timed out

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
#0      throwToolExit (package:flutter_tools/src/base/common.dart:10:3)
           #1      RunCommand.runCommand (package:flutter_tools/src/commands/run.dart:625:7)
           <asynchronous suspension>
           #2      FlutterCommand.verifyThenRunCommand (package:flutter_tools/src/runner/flutter_command.dart:1157:12)
           <asynchronous suspension>
           #3      FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:1009:27)
           <asynchronous suspension>
           #4      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
           <asynchronous suspension>
           #5      AppContext.run (package:flutter_tools/src/base/context.dart:149:12)
           <asynchronous suspension>
           #6      CommandRunner.runCommand (package:args/command_runner.dart:197:13)
           <asynchronous suspension>
           #7      FlutterCommandRunner.runCommand.<anonymous closure> (package:flutter_tools/src/runner/flutter_command_runner.dart:278:9)
           <asynchronous suspension>
           #8      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
           <asynchronous suspension>
           #9      AppContext.run (package:flutter_tools/src/base/context.dart:149:12)
           <asynchronous suspension>
           #10     FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:234:5)
           <asynchronous suspension>
           #11     run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:64:9)
           <asynchronous suspension>
           #12     run.<anonymous closure> (package:flutter_tools/runner.dart:62:12)
           <asynchronous suspension>
           #13     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
           <asynchronous suspension>
           #14     AppContext.run (package:flutter_tools/src/base/context.dart:149:12)
           <asynchronous suspension>
           #15     runInContext (package:flutter_tools/src/context_runner.dart:73:10)
           <asynchronous suspension>
           #16     main (package:flutter_tools/executable.dart:90:3)
           <asynchronous suspension>

这些跑不起来真机或模拟器的case,报一些io.flutter.xxx的问题,基本是因为仓库源下不下来。
解决方法:
1、在android/build.gradle中将google() jcenter()删掉,换成aliyun的仓库,外加一个download.flutter.io
2、在$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"中同样

buildscript {
    repositories {
        maven { url 'https://maven.aliyun.com/repository/google' }
        maven { url 'https://maven.aliyun.com/repository/jcenter' }
        maven { url 'http://maven.aliyun.com/nexus/content/groups/public' }
        maven { url 'http://download.flutter.io' }
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:4.1.0'
    }
}

allprojects {
    repositories {
        maven { url 'https://maven.aliyun.com/repository/google' }
        maven { url 'https://maven.aliyun.com/repository/jcenter' }
        maven { url 'http://maven.aliyun.com/nexus/content/groups/public' }
        maven { url 'http://download.flutter.io' }
    }
}

buildscript {
    repositories {
        maven { url 'https://maven.aliyun.com/repository/google' }
        maven { url 'https://maven.aliyun.com/repository/jcenter' }
        maven { url 'http://maven.aliyun.com/nexus/content/groups/public' }
    maven { url 'http://download.flutter.io' }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:4.1.0'
    }
}

安卓gradle插件和版本对应关系

插件版本 所需Gradle版本
1.0.0 - 1.1.3 2.2.1 - 2.3
1.2.0 - 1.3.1 2.2.1 - 2.9
1.5.0 2.2.1 - 2.13
2.0.0 - 2.1.2 2.10 - 2.13
2.1.3 - 2.2.3 2.14.1+
2.3.0+ 3.3+
3.0.0+ 4.1+
3.1.0+ 4.4+
3.2.0 - 3.2.1 4.6+
3.3.0 - 3.3.3 4.10.1+
3.4.0 - 3.4.3 5.1.1+
3.5.0 - 3.5.4 5.4.1+
3.6.0 - 3.6.4 5.6.4+
4.0.0+ 6.1.1+
4.1.0+ 6.5+

3.gradle问题

gradle是个人最深恶痛绝的一个东西,先吐为快!
首先他有gradle版本和插件的配套问题,和上面的图标一致。其次它自身很大,更新频繁,向下兼容性差,需要翻墙。
好了,言归正传。
每次编译都下载gradle-x.x-all.zip gradle-x.x.zip。每次都下不下来,等的想砸电脑。
解决方法:
1、环境变量里配置

export GRADLE_HOME=/usr/local/Cellar/gradle/wrapper/dists/gradle-6.1.1-all
export PATH=$PATH:${GRADLE_HOME}/bin

2、gradle-wrapper.properties中修改distributionUrl为file:///usr/local/Cellar/gradle/wrapper/dists/gradle-6.8.1-all.zip

distributionUrl=file:///usr/local/Cellar/gradle/wrapper/dists/gradle-6.8.1-all.zip

这个文件是

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
#distributionUrl=https://services.gradle.org/distributions/gradle-6.1.1-all.zip
distributionUrl=file:///usr/local/Cellar/gradle/wrapper/dists/gradle-6.8.1-all.zip

GRADLE_USER_HOME对应的是preferences里Build,Execution,Deployment中Gradle下的General settings下的Gradle user home。
distributionPath对应的是这个目录下的某一个目录。
zipStoreBase和zipStorePath顾名思义就是zip包的存储位置
distributionUrl是zip包的来源,默认是从https://services.gradle.org/distributions拿,我们改成从一个本地目录拿。
修改完之后,执行flutter clean flutter run --verbose即可看到不在downloading.

紧接着,你会遇到另一个问题,
卡在Starting a Gradle Daemon (subsequent builds will be faster)
解决方法:
切换网络,直到它开始执行。时间会长一些。

[+19195 ms] > Task :app:preBuild UP-TO-DATE
[        ] > Task :app:preDebugBuild UP-TO-DATE
[+1997 ms] > Task :flutter:compileFlutterBuildDebug
[        ] [ +115 ms] executing: [/Users/hyf/develop/flutter/] git -c log.showSignature=false log -n 1 --pretty=format:%H
[        ] [  +69 ms] Exit code 0 from: git -c log.showSignature=false log -n 1 --pretty=format:%H
[        ] [        ] 5aa6cba31d8a779ea11d2f5d37e39d3502a26bde
[        ] [        ] executing: [/Users/hyf/develop/flutter/] git tag --points-at 5aa6cba31d8a779ea11d2f5d37e39d3502a26bde
[        ] [  +85 ms] Exit code 0 from: git tag --points-at 5aa6cba31d8a779ea11d2f5d37e39d3502a26bde
[        ] [   +2 ms] executing: [/Users/hyf/develop/flutter/] git describe --match *.*.* --long --tags 5aa6cba31d8a779ea11d2f5d37e39d3502a26bde
[        ] [  +70 ms] Exit code 0 from: git describe --match *.*.* --long --tags 5aa6cba31d8a779ea11d2f5d37e39d3502a26bde
[        ] [        ] 1.26.0-12.0.pre-95-g5aa6cba31d
[        ] [  +64 ms] executing: [/Users/hyf/develop/flutter/] git rev-parse --abbrev-ref --symbolic @{u}
[        ] [  +16 ms] Exit code 0 from: git rev-parse --abbrev-ref --symbolic @{u}
[        ] [        ] origin/master
[        ] [        ] executing: [/Users/hyf/develop/flutter/] git ls-remote --get-url origin
[        ] [  +14 ms] Exit code 0 from: git ls-remote --get-url origin
[        ] [        ] https://github.com/flutter/flutter.git
[        ] [  +68 ms] executing: [/Users/hyf/develop/flutter/] git rev-parse --abbrev-ref HEAD
[        ] [  +16 ms] Exit code 0 from: git rev-parse --abbrev-ref HEAD
[        ] [        ] master
[        ] [  +52 ms] Artifact Instance of 'AndroidGenSnapshotArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'FlutterWebSdk' is not required, skipping update.
[        ] [   +3 ms] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
[        ] [  +75 ms] Artifact Instance of 'MaterialFonts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'GradleWrapper' is not required, skipping update.
[        ] [        ] Artifact Instance of 'AndroidGenSnapshotArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'FlutterWebSdk' is not required, skipping update.
[        ] [        ] Artifact Instance of 'FlutterSdk' is not required, skipping update.
[        ] [        ] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
[        ] [        ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'FontSubsetArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'PubDependencies' is not required, skipping update.
[        ] [  +88 ms] Initializing file store
[        ] [  +18 ms] Skipping target: gen_localizations
[        ] [   +8 ms] kernel_snapshot: Starting due to {}
[        ] [  +18 ms] /Users/hyf/develop/flutter/bin/cache/dart-sdk/bin/dart --disable-dart-dev
/Users/hyf/develop/flutter/bin/cache/artifacts/engine/darwin-x64/frontend_server.dart.snapshot --sdk-root
/Users/hyf/develop/flutter/bin/cache/artifacts/engine/common/flutter_patched_sdk/ --target=flutter --no-print-incremental-dependencies
-DFLUTTER_WEB_AUTO_DETECT=true -Ddart.vm.profile=false -Ddart.vm.product=false --enable-asserts --track-widget-creation --no-link-platform --packages
/Users/hyf/develop/ios/palfish/phonics/ai_app/.dart_tool/package_config.json --output-dill
/Users/hyf/develop/ios/palfish/phonics/ai_app/.dart_tool/flutter_build/0817f209a07422e16cc94a150e08c67e/app.dill --depfile
/Users/hyf/develop/ios/palfish/phonics/ai_app/.dart_tool/flutter_build/0817f209a07422e16cc94a150e08c67e/kernel_snapshot.d package:ai_app/main.dart
[+8989 ms] [+9586 ms] kernel_snapshot: Complete
[ +400 ms] [ +391 ms] debug_android_application: Starting due to {}
[ +297 ms] [ +297 ms] debug_android_application: Complete
[ +502 ms] [ +505 ms] Persisting file store
[        ] [   +7 ms] Done persisting file store
[        ] [   +5 ms] build succeeded.
[        ] [  +12 ms] "flutter assemble" took 11,038ms.
[        ] [   +3 ms] ensureAnalyticsSent: 0ms
[        ] [   +1 ms] Running shutdown hooks
[        ] [        ] Shutdown hooks complete
[        ] [        ] exiting with code 0
[ +197 ms] > Task :flutter:packLibsflutterBuildDebug
[        ] > Task :flutter:preBuild UP-TO-DATE
[        ] > Task :flutter:preDebugBuild UP-TO-DATE
[        ] > Task :flutter:compileDebugAidl NO-SOURCE
[        ] > Task :app:compileDebugAidl NO-SOURCE
[        ] > Task :flutter:packageDebugRenderscript NO-SOURCE
[        ] > Task :app:compileDebugRenderscript NO-SOURCE
[        ] > Task :app:generateDebugBuildConfig
[  +99 ms] > Task :app:generateDebugResValues
[        ] > Task :app:javaPreCompileDebug
[        ] > Task :flutter:writeDebugAarMetadata
[        ] > Task :app:generateDebugResources
[        ] > Task :flutter:compileDebugRenderscript NO-SOURCE
[        ] > Task :flutter:generateDebugResValues
[        ] > Task :flutter:generateDebugResources
[        ] > Task :flutter:packageDebugResources
[+29996 ms] > Task :app:mergeDebugResources
[+18599 ms] > Task :app:createDebugCompatibleScreenManifests
[        ] > Task :app:extractDeepLinksDebug
[        ] > Task :flutter:extractDeepLinksDebug
[  +99 ms] > Task :flutter:compileDebugLibraryResources
[ +101 ms] > Task :flutter:processDebugManifest
[ +502 ms] > Task :flutter:parseDebugLocalResources
[        ] > Task :app:checkDebugAarMetadata
[        ] > Task :flutter:generateDebugBuildConfig
[        ] > Task :flutter:javaPreCompileDebug
[        ] > Task :app:mergeDebugNativeDebugMetadata NO-SOURCE
[        ] > Task :app:mergeDebugShaders
[        ] > Task :app:compileDebugShaders NO-SOURCE
[        ] > Task :app:generateDebugAssets UP-TO-DATE
[        ] > Task :flutter:cleanPackageDebugAssets UP-TO-DATE
[        ] > Task :flutter:mergeDebugShaders
[        ] > Task :flutter:compileDebugShaders NO-SOURCE
[        ] > Task :flutter:generateDebugAssets UP-TO-DATE
[        ] > Task :flutter:packageDebugAssets
[ +295 ms] > Task :flutter:copyFlutterAssetsDebug
[ +300 ms] > Task :app:mergeDebugAssets
[        ] > Task :app:processDebugJavaRes NO-SOURCE
[        ] > Task :flutter:processDebugJavaRes NO-SOURCE
[        ] > Task :flutter:bundleLibResDebug NO-SOURCE
[ +600 ms] > Task :app:compressDebugAssets
[+14699 ms] > Task :app:mergeDebugJavaResource
[  +98 ms] > Task :app:checkDebugDuplicateClasses
[ +901 ms] > Task :app:mergeDebugJniLibFolders
[        ] > Task :flutter:mergeDebugJniLibFolders
[        ] > Task :flutter:mergeDebugNativeLibs NO-SOURCE
[        ] > Task :flutter:stripDebugDebugSymbols NO-SOURCE
[        ] > Task :flutter:copyDebugJniLibsProjectOnly
[  +99 ms] > Task :app:validateSigningDebug
[        ] > Task :flutter:copyDebugJniLibsProjectAndLocalJars
[        ] > Task :flutter:prepareLintJarForPublish
[        ] > Task :app:desugarDebugFileDependencies
[        ] > Task :flutter:mergeDebugJavaResource
[  +99 ms] > Task :app:processDebugMainManifest
[        ] [androidx.vectordrawable:vectordrawable-animated:1.0.0]
/Users/hyf/.gradle/caches/transforms-3/a6a0bb9725429dd49f389c7ed2e63cc4/transformed/vectordrawable-animated-1.0.0/AndroidManifest.xml Warning:
[        ]      Package name 'androidx.vectordrawable' used in: androidx.vectordrawable:vectordrawable-animated:1.0.0, androidx.vectordrawable:vectordrawable:1.0.1.
[ +399 ms] > Task :app:processDebugManifest
[ +100 ms] > Task :flutter:generateDebugRFile
[+2699 ms] > Task :app:mergeDebugNativeLibs
[+3699 ms] > Task :app:stripDebugDebugSymbols
[        ] Unable to strip the following libraries, packaging them as they are: libflutter.so.
[ +101 ms] > Task :app:mergeExtDexDebug
[+1198 ms] > Task :flutter:compileDebugJavaWithJavac
[        ] > Task :flutter:bundleLibRuntimeToJarDebug
[        ] > Task :flutter:bundleLibCompileToJarDebug
[+22200 ms] > Task :app:processDebugManifestForPackage
[+7799 ms] > Task :flutter:extractDebugAnnotations

执行到这里,又卡住了!
解决方法:
别急,换台设备 ,或者换成模拟器,或者模拟器换设备。切换网络等等。
出现下面的日志就算完全成功了!

[+5201 ms] > Task :flutter:extractDebugAnnotations
[  +97 ms] > Task :app:mergeExtDexDebug UP-TO-DATE
[ +101 ms] > Task :app:stripDebugDebugSymbols
[        ] > Task :flutter:mergeDebugGeneratedProguardFiles
[        ] > Task :flutter:mergeDebugConsumerProguardFiles
[        ] > Task :flutter:prepareLintJarForPublish UP-TO-DATE
[        ] > Task :flutter:mergeDebugJavaResource UP-TO-DATE
[        ] > Task :flutter:syncDebugLibJars
[+1899 ms] > Task :flutter:bundleDebugAar
[        ] > Task :flutter:compileDebugSources UP-TO-DATE
[        ] > Task :flutter:assembleDebug
[        ] > Task :app:processDebugManifestForPackage
[+1399 ms] > Task :app:processDebugResources
[ +799 ms] > Task :app:compileDebugJavaWithJavac
[        ] > Task :app:compileDebugSources
[ +400 ms] > Task :app:dexBuilderDebug
[ +999 ms] > Task :app:mergeDexDebug
[+1501 ms] > Task :app:packageDebug
[        ] > Task :app:assembleDebug
[        ] Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
[        ] Use '--warning-mode all' to show the individual deprecation warnings.
[        ] See https://docs.gradle.org/6.8.1/userguide/command_line_interface.html#sec:command_line_warnings
[        ] BUILD SUCCESSFUL in 18s
[        ] 55 actionable tasks: 20 executed, 35 up-to-date
[ +403 ms] Running Gradle task 'assembleDebug'... (completed in 19.0s)
[ +132 ms] calculateSha: LocalDirectory: '/Users/hyf/develop/ios/palfish/phonics/ai_app/build/host/outputs/apk'/app.apk
[  +15 ms] calculateSha: reading file took 14us
[ +407 ms] calculateSha: computing sha took 407us
[   +2 ms] ✓ Built build/host/outputs/apk/debug/app-debug.apk.
[   +6 ms] executing: /Users/hyf/develop_tool/android_sdk/sdk/build-tools/30.0.3/aapt dump xmltree
/Users/hyf/develop/ios/palfish/phonics/ai_app/build/host/outputs/apk/app.apk AndroidManifest.xml
[  +85 ms] Exit code 0 from: /Users/hyf/develop_tool/android_sdk/sdk/build-tools/30.0.3/aapt dump xmltree
/Users/hyf/develop/ios/palfish/phonics/ai_app/build/host/outputs/apk/app.apk AndroidManifest.xml
[        ] N: android=http://schemas.android.com/apk/res/android
             E: manifest (line=2)
               A: android:versionCode(0x0101021b)=(type 0x10)0x1
               A: android:versionName(0x0101021c)="1.0" (Raw: "1.0")
               A: android:compileSdkVersion(0x01010572)=(type 0x10)0x1e
               A: android:compileSdkVersionCodename(0x01010573)="11" (Raw: "11")
               A: package="com.duwo.ai.host" (Raw: "com.duwo.ai.host")
               A: platformBuildVersionCode=(type 0x10)0x1e
               A: platformBuildVersionName=(type 0x10)0xb
               E: uses-sdk (line=7)
                 A: android:minSdkVersion(0x0101020c)=(type 0x10)0x10
                 A: android:targetSdkVersion(0x01010270)=(type 0x10)0x1e
               E: uses-permission (line=16)
                 A: android:name(0x01010003)="android.permission.INTERNET" (Raw: "android.permission.INTERNET")
               E: application (line=18)
                 A: android:label(0x01010001)="ai_app" (Raw: "ai_app")
                 A: android:icon(0x01010002)=@0x7f0a0000
                 A: android:debuggable(0x0101000f)=(type 0x12)0xffffffff
                 A: android:appComponentFactory(0x0101057a)="androidx.core.app.CoreComponentFactory" (Raw: "androidx.core.app.CoreComponentFactory")
                 E: activity (line=23)
                   A: android:theme(0x01010000)=@0x7f0c00a0
                   A: android:name(0x01010003)="com.duwo.ai.host.MainActivity" (Raw: "com.duwo.ai.host.MainActivity")
                   A: android:launchMode(0x0101001d)=(type 0x10)0x1
                   A: android:configChanges(0x0101001f)=(type 0x11)0x40003fb4
                   A: android:windowSoftInputMode(0x0101022b)=(type 0x11)0x10
                   A: android:hardwareAccelerated(0x010102d3)=(type 0x12)0xffffffff
                   E: meta-data (line=37)
                     A: android:name(0x01010003)="io.flutter.app.android.SplashScreenUntilFirstFrame" (Raw: "io.flutter.app.android.SplashScreenUntilFirstFrame")
                     A: android:value(0x01010024)=(type 0x12)0xffffffff
                   E: intent-filter (line=41)
                     E: action (line=42)
                       A: android:name(0x01010003)="android.intent.action.MAIN" (Raw: "android.intent.action.MAIN")
                     E: category (line=44)
                       A: android:name(0x01010003)="android.intent.category.LAUNCHER" (Raw: "android.intent.category.LAUNCHER")
                 E: meta-data (line=51)
                   A: android:name(0x01010003)="flutterEmbedding" (Raw: "flutterEmbedding")
                   A: android:value(0x01010024)=(type 0x10)0x2
                 E: meta-data (line=54)
                   A: android:name(0x01010003)="flutterProjectType" (Raw: "flutterProjectType")
                   A: android:value(0x01010024)="module" (Raw: "module")
[   +6 ms] Stopping app 'app.apk' on Android SDK built for x86.
[        ] executing: /Users/hyf/develop_tool/android_sdk/sdk/platform-tools/adb -s emulator-5554 shell am force-stop com.duwo.ai.host
[  +77 ms] executing: /Users/hyf/develop_tool/android_sdk/sdk/platform-tools/adb -s emulator-5554 shell pm list packages com.duwo.ai.host
[  +55 ms] Installing APK.
[   +1 ms] Installing build/host/outputs/apk/app.apk...
[        ] executing: /Users/hyf/develop_tool/android_sdk/sdk/platform-tools/adb -s emulator-5554 install -t -r
/Users/hyf/develop/ios/palfish/phonics/ai_app/build/host/outputs/apk/app.apk
[+2677 ms] Success
[   +1 ms] Installing build/host/outputs/apk/app.apk... (completed in 2,678ms)
[   +1 ms] executing: /Users/hyf/develop_tool/android_sdk/sdk/platform-tools/adb -s emulator-5554 shell echo -n f68556d6dff8262529ab8d91f5ab6ced4bcbd98b >
/data/local/tmp/sky.com.duwo.ai.host.sha1
[  +44 ms] executing: /Users/hyf/develop_tool/android_sdk/sdk/platform-tools/adb -s emulator-5554 shell -x logcat -v time -t 1
[ +158 ms] --------- beginning of system
                    01-29 17:08:09.747 W/ActivityManager( 2020): Slow operation: 122ms so far, now at startProcess: asking zygote to start proc
[   +6 ms] executing: /Users/hyf/develop_tool/android_sdk/sdk/platform-tools/adb -s emulator-5554 shell am start -a android.intent.action.RUN -f 0x20000000 --ez
enable-background-compilation true --ez enable-dart-profiling true --ez enable-checked-mode true --ez verify-entry-points true
com.duwo.ai.host/com.duwo.ai.host.MainActivity
[ +300 ms] Starting: Intent { act=android.intent.action.RUN flg=0x20000000 cmp=com.duwo.ai.host/.MainActivity (has extras) }
[        ] Waiting for observatory port to be available...
[+2715 ms] Observatory URL on device: http://127.0.0.1:34755/tPV1ZgZA--U=/
[        ] executing: /Users/hyf/develop_tool/android_sdk/sdk/platform-tools/adb -s emulator-5554 forward tcp:0 tcp:34755
[  +12 ms] 61444
[        ] Forwarded host port 61444 to device port 34755 for Observatory
[   +3 ms] Caching compiled dill
[  +78 ms] Connecting to service protocol: http://127.0.0.1:61444/tPV1ZgZA--U=/
[ +320 ms] Launching a Dart Developer Service (DDS) instance at http://127.0.0.1:0, connecting to VM service at http://127.0.0.1:61444/tPV1ZgZA--U=/.
[ +461 ms] DDS is listening at http://127.0.0.1:61450/95Jbzaefkko=/.
[  +54 ms] Successfully connected to service protocol: http://127.0.0.1:61444/tPV1ZgZA--U=/
[ +697 ms] DevFS: Creating new filesystem on the device (null)
[  +91 ms] DevFS: Created new filesystem on the device (file:///data/user/0/com.duwo.ai.host/code_cache/ai_appOWTMQQ/ai_app/)
[   +2 ms] Updating assets
[ +103 ms] Syncing files to device Android SDK built for x86...
[   +2 ms] <- reset
[        ] Compiling dart to kernel with 0 updated files
[   +3 ms] <- recompile package:ai_app/main.dart 367dbbe2-ccc9-4d87-a27f-c33d3de374ef
[        ] <- 367dbbe2-ccc9-4d87-a27f-c33d3de374ef
[ +141 ms] Updating files.
[        ] DevFS: Sync finished
[        ] Syncing files to device Android SDK built for x86... (completed in 147ms)
[        ] Synced 0.0MB.
[   +1 ms] <- accept
[  +14 ms] Connected to _flutterView/0xd27a2c10.

Starting a Gradle Daemon, 2 busy Daemons could not be reused, use --status for details

关掉精灵进程可以用 gradle stop他会告诉你 No Gradle daemons are running. 但是仍然会卡住。

Starting a Gradle Daemon, 2 stopped Daemons could not be reused, use --status for details
 gradle --status
   PID STATUS   INFO
 61498 IDLE     6.8.1
 59750 STOPPED  (stop command received)
 57879 STOPPED  (by user or operating system)

卡住的原因是同步的,需要在gradle全局配置中设置为支持并行

解决方法:

/home/<username>/.gradle/ (Linux)
/Users/<username>/.gradle/ (Mac)
C:\Users\<username>\.gradle (Windows)

在如上目录中找到gradle.properties(没有就创建一个)
加上下面两句

org.gradle.daemon=true

org.gradle.parallel=true

iOS问题

1.iOS真机无法打开“iproxy”,因为无法验证开发者。

无法打开“ idevice_id”,因为无法验证开发者。
无法打开“ idevicename”,因为无法验证开发者。
无法打开“ idevicescreenshot”,因为无法验证开发者。
无法打开“ idevicesyslog”,因为无法验证开发者。
无法打开“ ideviceinfo”,因为无法验证开发者。
这都是一类问题
执行如下命令,就可以了。

sudo spctl --master-disable

sudo xattr -r -d com.apple.quarantine {flutter目录}/bin/cache/artifacts/libimobiledevice/idevice_id
sudo xattr -r -d com.apple.quarantine {flutter目录}/bin/cache/artifacts/libimobiledevice/idevicename
sudo xattr -r -d com.apple.quarantine {flutter目录}/bin/cache/artifacts/libimobiledevice/idevicescreenshot
sudo xattr -r -d com.apple.quarantine {flutter目录}/bin/cache/artifacts/libimobiledevice/idevicesyslog
sudo xattr -r -d com.apple.quarantine {flutter目录}/bin/cache/artifacts/libimobiledevice/ideviceinfo
sudo xattr -d com.apple.quarantine {flutter目录}/bin/cache/artifacts/usbmuxd/iproxy
2、iOS<Flutter/Flutter.h>文件找不到问题

/Users/hyf/develop/ios/demos/AI/f_ai/.ios/Flutter/FlutterPluginRegistrant/Classes/GeneratedPluginRegistrant.h:8:9: 'Flutter/Flutter.h' file not found

需要flutter版本和cocoapods版本对应,1.22版本需要和cocoapods1.10.x匹配。
执行sudo gem install cocoapods,删除Podfile.lock,然后执行pod install即可。
这个坑历史版本也出现过。比如flutter0.2.x必须匹配cocoapods1.4 https://github.com/flutter/flutter/issues/16036,总之,flutter doctor中建议你用什么版本就用什么版本,千万不要相信它的兼容性。

3、flutter Waiting for iPad to report its views

从master更换到stable之后,一直就跑不起来。报这个错,屏幕白屏,卡在那里。
需要 flutter cleanflutter run

四、更新相关

对web的支持是在beta channel中的。stable channel暂未支持。
切换channel使用flutter channel stableflutter channel beta,稳定性上stable要比beta高的多,但beta代码要新的多.beta分支上,不仅flutter的代码是beta的,连依赖也是beta的,如dart
比如

>flutter upgrade
Flutter is already up to date on channel beta
Flutter 1.25.0-8.3.pre • channel beta • https://github.com/flutter/flutter.git
Framework • revision 5d36f2e7f5 (6 天前) • 2021-01-14 15:57:49 -0800
Engine • revision 7a8f8ca02c
Tools • Dart 2.12.0 (build 2.12.0-133.7.beta)

官方建议要使用package,不要使用pub. 不明白这两个有啥区别,麻烦知道的大大们留言告知一下。
不要使用pub get或pub upgrade命令来管理你的依赖关系。相反,应该使用flutter packages get或flutter packages upgrade。如果您想手动使用pub,则可以通过设置FLUTTER_ROOT环境变量来直接运行它。

五、仓库

.gitignore的生成
1、标准化:https://www.toptal.com/developers/gitignore
2、前辈实践:https://github.com/flutter/flutter/issues/13892

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 212,222评论 6 493
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 90,455评论 3 385
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 157,720评论 0 348
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 56,568评论 1 284
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 65,696评论 6 386
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 49,879评论 1 290
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 39,028评论 3 409
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 37,773评论 0 268
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 44,220评论 1 303
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 36,550评论 2 327
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 38,697评论 1 341
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 34,360评论 4 332
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 40,002评论 3 315
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 30,782评论 0 21
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,010评论 1 266
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 46,433评论 2 360
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 43,587评论 2 350

推荐阅读更多精彩内容