React-Native项目回忆
创建项目:npx @react-native-community/cli init AwesomeProject
创建tv电视项目:https://github.com/react-native-tvos/react-native-tvos?tab=readme-ov-file
运行:npx react-native run-android
打包:
1. 生成一个签名密钥:
$ keytool -genkeypair -v -storetype PKCS12 -keystore my-release-key.keystore -alias my-key-alias -keyalg RSA -keysize 2048 -validity 10000
2. 设置 gradle 变量
项目目录/android/gradle.properties
(项目配置,只对所在项目有效)
MYAPP_RELEASE_STORE_FILE=my-release-key.keystore
MYAPP_RELEASE_KEY_ALIAS=my-key-alias
MYAPP_RELEASE_STORE_PASSWORD=*****
MYAPP_RELEASE_KEY_PASSWORD=*****
3. 把签名配置加入到项目的 gradle 配置中
...
android {...defaultConfig { ... }signingConfigs {release {if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {storeFile file(MYAPP_RELEASE_STORE_FILE)storePassword MYAPP_RELEASE_STORE_PASSWORDkeyAlias MYAPP_RELEASE_KEY_ALIASkeyPassword MYAPP_RELEASE_KEY_PASSWORD}}}buildTypes {release {...signingConfig signingConfigs.release}}
}
...
4. 生成发行 APK 包
$ cd android
$ ./gradlew assembleRelease
发现apk包网路环境配置
1、在android/app/src/main/res目录下新建一个xml目录,在xml目录中新建名为network_security_config.xml的 文件,内容如下
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<base-config cleartextTrafficPermitted="true" />
</network-security-config>
2、在android/app/src/main目录下的AndroidManifest.xml文件中application标签内声明文件
android:networkSecurityConfig="@xml/network_security_config"