How to Build This Project#

Server#

For development build, see Server Development

For actual deployment to a production environment, see Deployment Guide

client-pc#

Considering performance and labor cost issues, we have decided to terminate the development of the Py client and switch to developing the client with Flutter.

Flutter client#

Environment Configuration#

Select your operating system below to go to the setup tutorial to install Flutter

Install protoc#

For details, please refer to the official documentation

Download official-compiled version ProtobufFrom Github.It will be used to compile proto file

Extract the downloaded files to any location and add to environment variables

Install the protocol compiler plugin for Dart#

For details, please refer to the official documentation

dart pub global activate protoc_plugin 25.0.0

Add the Pub cache path to environment variables

If you are a Windows user, the default path is C:/Users/%username%/AppData/Local/Pub/Cache/bin

If you are a Mac/Linux user, add ~/.pub-cache/bin to environment variables

Install dependencies#

cd ./client/pc/ourchat # 进入目录
flutter pub get # 安装依赖

Generate code#

Run at the root directory of this project

# 生成grpc service相关代码
python ./script/generate.pb.dart.py

Argument

Meaning

Optional

afdian_userid

The user ID on the Aifadian platform, used for obtaining the donor list.

afdian_token

The token on the Aifadian platform, used for obtaining the donor list.

version

Version Id of current version

×

commit_sha

commit_sha of current version

×

After it is completed, enter the client directory and run it

cd ./client # 进入客户端目录
# 生成数据库ORM相关代码
dart run build_runner build

Run the project#

cd ./client # 进入客户端目录
flutter run

# 会出现如下界面,选择你希望运行的平台即可
> Connected devices:
> Windows (desktop)  windows  windows-x64     Microsoft Windows [版本 xxx]
> Chrome (web)       chrome   web-javascript  Google Chrome xxx
> Edge (web)         edge     web-javascript  Microsoft Edge xxx
> [1]: Windows (windows)
> [2]: Chrome (chrome)
> [3]: Edge (edge)
> Please choose one (or "q" to quit):

Build as an executable file#

Regular Build#

Go to the client directory and run the project

# 生成编译变量
python ./script/generate_about_code.py --afdian_userid userid --afdian_token token --version v0.1.0.beta --commit_sha 123456abc
cd ./client # 进入目录
flutter build # 查看可供构建的平台

# 会出现可构建的平台列表,如:
> Available subcommands:
>   aar         Build a repository containing an AAR and a POM file.
>   apk         Build an Android APK file from your app.
>   appbundle   Build an Android App Bundle file from your app.
>   bundle      Build the Flutter assets directory from your app.
>   web         Build a web application bundle.
>   windows     Build a Windows desktop application.

# 选择你想要构建的平台即可,这里选择windows为例
flutter build windows

# 构建完成后会显示可执行文件的目录

Enable version check#

Just add the --enable_version_check parameter when generating the compiled variable

python ./script/generate_about_code.py --afdian_userid userid --afdian_token token --version v0.1.0.beta --commit_sha 123456abc --enable_version_check

Build and Sign the APK#

We strongly recommend signing the APK during the build process. If you do not plan to sign it for the time being, you can skip directly.

You need to prepare:

  • Keystore file and key

  • YOUR HAND

sgstr “Copy the keystore file to client/android/app, and create a new key.properties file in the same directory with the following content:

storePassword = <storePassword>
keyPassword = <keyPassword>
keyAlias = key
storeFile = <storeFile>

For example

storePassword = test123
keyPassword = test123
keyAlias = key
storeFile = key.jks

Next, you just need to execute the following command in the client directory

flutter build apk --dart-define-from-file=build.json --release -PuseReleaseSigning=true