package.json说明

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40

{
"name": "app_name",//应用名
"version": "1.1.1",//版本,用于展示
"versionCode": 99,//版本号
"private": true,
"scripts": { //常用的命令封装
"start": "",
"clear": "",
"publish": "",
"android": "",
"ios": ""
},
"engines": {},
"repository": {
"type": "git",
"url": ""
},
"keywords": {},
"author": {
"name": "",
"email": ""
},
"license": "",
"bugs": {
"url": ""
},
"homepage": {},
"dependencies": {//项目的依赖
"react": "18.2.0",
"react-native": "0.71.7"
},
"resolutions":{ /* 强制依赖, 只在yarn中有效,npm不支持此字段 */
"@types/react": "^17"
},
"devDependencies": {//开发的时候依赖

}
}

环境搭建

Mac 环境搭建

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# 安装node
brew install node

# 安装文件监控,方便开发
brew install watchman

# 使用nrm工具切换淘宝源
npx nrm use taobao

# 如果之后需要切换回官方源可使用
npx nrm use npm

# Yarn是Facebook提供的替代npm的工具,可以加速node模块的下载
npm install -g yarn

# 安装java环境

# 安装Android开发环境

Read More

flutter Android端编译流程

Android编译源码流程

settings.gradle配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// 当前 app module
include ':app'

/**
* 1、读取android/local.properties文件内容
* 2、获取flutter.sdk的值,也就是你本地flutter SDK安装目录
* 3、gradle 脚本常规操作 apply flutter SDK路径下/packages/flutter_tools/gradle/app_plugin_loader.gradle文件
*/
def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
def properties = new Properties()

assert localPropertiesFile.exists()
localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }

def flutterSdkPath = properties.getProperty("flutter.sdk")
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle"

查看app_plugin_loader.gradle文件

Read More