2024 安装体验 React Native
npx react-native@latest init AwesomeProject
项目/android -> gradle -> wrapper -> gradle-wrapper.properties
distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists # distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-all.zip distributionUrl=file\:///d:/gradle/gradle-8.8-all.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists
项目/android ->build.gradle
配置好 yarn android 时 下载grade plugin快一些 和 run android debug快一些
buildscript {
ext {
buildToolsVersion = "34.0.0"
minSdkVersion = 23
compileSdkVersion = 34
targetSdkVersion = 34
ndkVersion = "26.1.10909125"
kotlinVersion = "1.9.22"
}
repositories {
maven { url 'https://mirrors.cloud.tencent.com/gradle/' }
maven{ url 'https://maven.aliyun.com/repository/google'}
// maven{
// allowInsecureProtocol true
// url "https://maven.aliyun.com/repository/public"
// }
google()
mavenCentral()
}
dependencies {
classpath("com.android.tools.build:gradle")
classpath("com.facebook.react:react-native-gradle-plugin")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin")
}
}
allprojects {
repositories {
maven{ url 'https://maven.aliyun.com/repository/google'} //重点关注这一行
google()
jcenter()
}
}
apply plugin: "com.facebook.react.rootproject"
注意对应版本https://docs.gradle.org/current/userguide/compatibility.html
我用的是java17 项目用gradle8.8 环境变量gradle-8.8 react-native@latest=13.6.8
打包慢 https://juejin.cn/post/7263035160622317626

浙公网安备 33010602011771号