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