2024 安装体验 React Native

npx react-native@latest init AwesomeProject

配置gradle https://blog.csdn.net/weixin_44843569/article/details/120873183

gradle 下载慢 https://blog.csdn.net/liyu_ya/article/details/129403811

 

项目/android -> gradle -> wrapper -> gradle-wrapper.properties

1
2
3
4
5
6
7
8
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快一些

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
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

posted @   KooTeam  阅读(45)  评论(0编辑  收藏  举报
点击右上角即可分享
微信分享提示