关于flutter:Flutter-Notes-|-记录基于-macOS-上使用-Flutter-过程中遇到的一些问题

43次阅读

共计 5848 个字符,预计需要花费 15 分钟才能阅读完成。

点滴积攒,追随鸡老大~

前言

每当接触一个新货色,总是会遇到一些想喷人的问题,尽管在前期回过头想想,好简略,当初怎么就掉坑出不来了呢?

正好公司最近来个新我的项目,从 Flutter 进去到当初始终处于偷窥状态,恰好逢此机会,Flutter 搞起来~

记录本人 Flutter 应用过程遇到的一些问题,心愿能够帮忙和我一样刚入坑的小伙伴~

缓缓积攒吧~

问题收集

千里之行; 始于足下,一起变得更好~

1. Waiting for another flutter command to release the startup lock…

iTerm 中键入如下内容:

killall -9 dart

2. Could not determine the dependencies of task ‘:app:compileDebugJavaWithJavac’.

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
> Could not resolve all task dependencies for configuration ':app:debugCompileClasspath'.
   > Could not resolve io.flutter:flutter_embedding_debug:1.0.0-540786dd51f112885a89792d678296b95e6622e5.
     Required by:
         project :app
      > Skipped due to earlier error
      > Skipped due to earlier error
      > Skipped due to earlier error
   > Could not resolve io.flutter:arm64_v8a_debug:1.0.0-540786dd51f112885a89792d678296b95e6622e5.
     Required by:
         project :app
      > Skipped due to earlier error
      > Skipped due to earlier error
      > Skipped due to earlier error
   > Could not resolve io.flutter:x86_debug:1.0.0-540786dd51f112885a89792d678296b95e6622e5.
     Required by:
         project :app
      > Skipped due to earlier error
      > Skipped due to earlier error
      > Skipped due to earlier error
   > Could not resolve io.flutter:x86_64_debug:1.0.0-540786dd51f112885a89792d678296b95e6622e5.
     Required by:
         project :app
      > Skipped due to earlier error
      > Skipped due to earlier error
      > Skipped due to earlier error

* 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.

* Get more help at https://help.gradle.org

BUILD FAILED in 2m 9s
Exception: Gradle task assembleDebug failed with exit code 1

掘友很贴心的指导我是 因为依赖没有下载下来导致的

上面提供三种形式,多多尝试:

  • 将 VPN 设置为全局代理模式;
  • 替换 Android 依赖源为阿里云,感激 逝水流光;
maven {url 'https://maven.aliyun.com/repository/googlemaven.aliyun.com/repository/goo...'}
maven {url 'https://maven.aliyun.com/repository/jcentermaven.aliyun.com/repository/jce...'}
maven {url 'http://maven.aliyun.com/nexus/content/groups/publicmaven.aliyun.com/nexus/content/...'}
  • 尝试 flutter clean 清理下,感激 爱 coding 真的太好了

3. If you’re running an application and need to access the binary messenger before runApp() has been called (for example, during plugin initialization), then you need to explicitly call the WidgetsFlutterBinding.ensureInitialized() first.

如日志提醒一样,在 runApp() 前调用 WidgetsFlutterBinding.ensureInitialized()。

4. [!] Invalid Podfile file: [!] Specifying multiple post_install hooks is unsupported..

Podfile 只能有一个 post_install,所以合并到一个外面就好,我这纯正野路子解决方案。

5. Error running ‘splash.dart’: Entrypoint doesn’t contain a main function

检测 main.dart 目录地址是否正确。

6.AAPT: error: failed to read PNG signature: file does not start with PNG signature.

问题起因是对方提供我一张 jpg 的图片,我间接批改后缀为 png 了。

解决办法:在 app/build.gradle 中新增如下:

aaptOptions {cruncherEnabled = false}

作用就是告诉 Android Studio 别查看我图片的有效性了。

7.Could not find the built application bundle at build/ios/iphoneos/Runner.app.

因为 Leader 批改了 iOS 名称,所以我在 Android Studio 中间接抉择运行 iOS 始终不胜利,因为它指标是将 Runner 运行指标设施上,然而理论却生成了 Leader 批改后的包名字,所以间接导致找不到 Runner。

批改形式:

  • 将 Display Name 批改为 Runner 即可,如下图:

8.The builder for route “/actionDetailPage?loadUrl=https://guokr.com” returned null.

这个问题吧,我也有点懵,先放一下谬误日志:

════════ Exception caught by widgets library ═══════════════════════════════════════════════════════
The following assertion was thrown building Builder(dirty):
The builder for route "/actionDetailPage?loadUrl=https://guokr.com" returned null.

Route builders must never return null.
The relevant error-causing widget was: 
  MaterialApp file:///Users/heliquan/CodePro/FlutterPro/haozhuan_app/lib/main.dart:34:12
When the exception was thrown, this was the stack: 
#0      CupertinoPageRoute.buildPage.<anonymous closure> (package:flutter/src/cupertino/route.dart:260:9)
#1      CupertinoPageRoute.buildPage (package:flutter/src/cupertino/route.dart:266:6)
#2      _ModalScopeState.build.<anonymous closure> (package:flutter/src/widgets/routes.dart:804:43)
#3      Builder.build (package:flutter/src/widgets/basic.dart:6998:48)
#4      StatelessElement.build (package:flutter/src/widgets/framework.dart:4576:28)
...

这个问题我也比拟懵逼,跳转传递值,很 easy 的货色,而且我传递的是一个地址链接,又不是含有中文的货色。

But,死活不行,网上各种搜。

最初,想着要不然本义下吧。后果,好了。

NavigatorUtil.jumpFormRight(context,
                    '${Routes.actionDetailPage}?loadUrl=${Uri.encodeComponent(mActionList[index].url)}');

难道传递 URL 都不能间接传?

回头哪儿天试试。

9. uses-sdk:minSdkVersion 17 cannot be smaller than version 19 declared in library(2020-07-12)

日志如下:

/Users/HLQ/CodePro/FlutterPro/xxx_app/android/app/src/profile/AndroidManifest.xml Error:
        uses-sdk:minSdkVersion 17 cannot be smaller than version 19 declared in library [com.mob.push.plugins:oppo:2.1.0] /Users/HLQ/.gradle/caches/transforms-2/files-2.1/91fa5aa891331ae54500dada38fa5849/oppo-2.1.0/AndroidManifest.xml as the library might be using APIs not available in 17
        Suggestion: use a compatible library with a minSdk of at most 17,
                or increase this project's minSdk version to at least 19,
                or use tools:overrideLibrary="com.heytap.mcssdk" to force usage (may lead to runtime failures)

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processProfileManifest'.
> Manifest merger failed : uses-sdk:minSdkVersion 17 cannot be smaller than version 19 declared in library [com.mob.push.plugins:oppo:2.1.0] /Users/HLQ/.gradle/caches/transforms-2/files-2.1/91fa5aa891331ae54500dada38fa5849/oppo-2.1.0/AndroidManifest.xml as the library might be using APIs not available in 17
        Suggestion: use a compatible library with a minSdk of at most 17,
                or increase this project's minSdk version to at least 19,
                or use tools:overrideLibrary="com.heytap.mcssdk" to force usage (may lead to runtime failures)

* 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.

* Get more help at https://help.gradle.org

我得解决方案是:

  • 批改 build 文件中的 minSdk 改为 19,最初同步即可

11. GC overhead limit exceeded(2020-07-13)

日志如下:

[+44802 ms] FAILURE: Build failed with an exception.
[+4 ms] * What went wrong:
[ ] Failed to notify build listener.
[ ] > GC overhead limit exceeded
[ ] * 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.
[ ] * Get more help at https://help.gradle.org
[] BUILD FAILED in 1m 1s

批改计划如下:

gradle.properties:

  • org.gradle.jvmargs=-Xmx4096M

app build 中增加:

dexOptions {javaMaxHeapSize "4g"}

Thanks

  • Waiting for another flutter command to release the startup lock
  • 掘金

正文完
 0