学习Flutter遇到的问题汇总(持续更新中.....)

1.Flutter打包apk报错:Your app isn't using AndroidX.

此问题是项目们使用AndroidX导致的解决办法代开项目中android目录中的gradle.properties文件加入以下两行代码

android.enableJetifier=true
android.useAndroidX=true

然后运行就OK了

2.flutter run后提示CachedNetworkImageProvider.load的异常,错误日志如下

Compiler message:
/D:/flutterSdk/flutter/.pub-cache/hosted/pub.flutter-io.cn/cached_network_image-1.1.0/lib/src/cached_network_image_provider.dart:42:24: Error: The method 'CachedNetworkImageProvider.load' has fewer positional arguments than those of overridden method 'ImageProvider.load'.
  ImageStreamCompleter load(CachedNetworkImageProvider key) {                ^
/D:/flutterSdk/flutter/packages/flutter/lib/src/painting/image_provider.dart:403:24: Context: This is the overridden method ('load').
  ImageStreamCompleter load(T key, DecoderCallback decode);
                       ^
Target kernel_snapshot failed: Exception: Errors during snapshot creation: null
build failed.

FAILURE: Build failed with an exception.

解决办法如下:

打开pubspec.yaml文件,修改cached_network_image版本从原来的 1.1.0修改为2.0.0-rc,然后点击Packages get 完成.

发现又报另一个错误如下

Running "flutter pub get" in FlutterDouBan...                   
Because cached_network_image 2.0.0-rc depends on flutter_cache_manager ^1.1.2 and doubanapp depends on flutter_cache_manager 1.1.0, cached_network_image 2.0.0-rc is forbidden.

再次修改pubspec.yaml文件,把flutter_cache_manager版本更改1.1.2就可以

3.如果使用exoplayer报错如下

video_player: Could not find com.google.android.exoplayer:exoplayer-core:2.x.x...................

解决办法

打开android文件下的build.gradel添加如下代码

  maven {
            url 'http://repo.spring.io/plugins-release/'
        }

具体位置如下图

学习Flutter遇到的问题汇总(持续更新中.....)_第1张图片

你可能感兴趣的:(学习Flutter遇到的问题汇总(持续更新中.....))