记录运行OpenIMFlutterDemo过程

前言:好久没怎么研究过技术了,最近不忙了,继续捡起之前玩过的flutter来学习下,本来只是随便跑一个demo学习下,结果发现一路都是坑,特记录一下

一、准备安装环境
入门: 在macOS上搭建Flutter开发环境
1.1、讲flutter克隆到本地上
git clone https://github.com/flutter/flutter.git
1.2 配置flutter克隆后的文件夹下环境path 文件~/.bash_profile
export PATH=/xxx/xxx/flutter/bin:$PATH
source ~/.bash_profile
1.3 iOS配置cocoapods、安装xcode过程略
1.4 Android下载Android studio过程略


二、正式运行demo
地址:OpenIMFlutterDemo:https://github.com/hrxiang/OpenIMFlutterDemo

2.1 iOS

下载好后准备运行iOS模拟器,结果运行后发现swift写的各种库报错,以及一些方法找不到,截图如下


截屏2021-08-05 00.44.18.png

经过查看issues,发现作者有回复说目前iOS版本还不能使用,只能先放弃
https://github.com/OpenIMSDK/Open-IM-SDK-Flutter/issues/17

截屏2021-08-05 00.47.23.png

2.2 Android

2.2.1 运行demo报的第一个错误
pub get failed (66; Because eechart depends on flutter_openim_sdk from path
which doesn't exist (could not find package flutter_openim_sdk at
"../Open-IM-SDK-Flutter"), version solving failed.)

原因是demo里pubspec.yaml直接使用了引入相对文件夹的方式引入Open-IM-SDK-Flutter,这可能是作者本地调试时这样写比较方便,但一般用户本地没有这样的文件,只需要将这个库配置成git远程的方式就可以了
path: ../Open-IM-SDK-Flutter改成git: url: https://github.com/hrxiang/flutter_background.git, 如下图

截屏2021-08-05 00.56.09.png

2.2.2 找不到assets/data,这个错不影响运行,在pubspec.yaml注释掉即可
Error: unable to find directory entry in pubspec.yaml: /xxx/xxx/OpenIMFlutterDemo/assets/data/
2.2.3 Error: The argument type 'PointerEvent' can't be assigned to the parameter type 'PointerDownEvent'.
../../../../../.pub-cache/hosted/pub.dartlang.org/photo_view-0.11.1/lib/src/core/photo_view_gesture_detector.dart:106:29: Error: The argument type 'PointerEvent' can't be assigned to the parameter type 'PointerDownEvent'.
 - 'PointerEvent' is from 'package:flutter/src/gestures/events.dart' ('../../../../flutterSDK/flutter/packages/flutter/lib/src/gestures/events.dart').
 - 'PointerDownEvent' is from 'package:flutter/src/gestures/events.dart' ('../../../../flutterSDK/flutter/packages/flutter/lib/src/gestures/events.dart').
    super.addAllowedPointer(event);

这个问题是因为引入的库photo_view版本有更新,demo里pubspec.yaml引入的是photo_view: ^0.11.1,改成photo_view: ^0.12.0即可
查询库的最新版本网站:https://pub.flutter-io.cn/packages

截屏2021-08-05 01.07.15.png

2.2.4
/xxx/xxx/OpenIMFlutterDemo/build/flutter_openim_sdk/intermediates/local_only_symbol_list/debug/R-def.txt' specified for property 'localResourcesFile' does not exist

解决方案:关闭debug模式下的混淆开关shrinkResources true

截屏2021-08-05 01.29.31.png

截屏2021-08-05 01.30.07.png

结果:虽然历经断断续续好几天查找资料,终于在Oppo真机上运行起来了,接下来就可以继续里面的实质内容的学习了


Screenshot_2021-08-05-01-33-46-17_f518629e48c204f01c07d63315738ce8.jpg
Screenshot_2021-08-05-01-33-59-87_f518629e48c204f01c07d63315738ce8.jpg
Screenshot_2021-08-05-01-34-07-34_f518629e48c204f01c07d63315738ce8.jpg
Screenshot_2021-08-05-01-34-12-94_f518629e48c204f01c07d63315738ce8.jpg

付上Oppo开启调试模式的方式:
设置- >关于手机->版本号 快速多次点击
https://zhidao.baidu.com/question/1579785803788728860.html

推荐阅读更多精彩内容