react-native 搭建项目

1、android sdk 安装

react-native 搭建项目_第1张图片

2、android环境配置

C:\Users\Administrator\AppData\Local\Android\Sdk/3、path 配置

react-native 搭建项目_第2张图片

4、创建项目

npx @react-native-community/cli init AwesomeProject

5、路由跳转

import {createNativeStackNavigator} from '@react-navigation/native-stack';

  6、rnmapbox安装流程


AndroidStudio启动项目报错error Failed to launch emulator. Reason: No emulators found as an output of `emul-CSDN博客

buildscript {
    ext {
        buildToolsVersion = "35.0.0"
        minSdkVersion = 28
        compileSdkVersion = 35
        targetSdkVersion = 34
        ndkVersion = "27.1.12297006"
//        ndkVersion = "26.1.10909125"
        kotlinVersion = "2.0.21"
        RNMapboxMapsImpl = 'mapbox'
    }
    repositories {
        maven { url 'https://maven.aliyun.com/repository/central' }
        maven { url 'https://maven.aliyun.com/repository/jcenter' }
        maven { url 'https://maven.aliyun.com/repository/google' }
        maven { url 'https://maven.aliyun.com/repository/public' }
        maven { url 'https://maven.aliyun.com/repository/gradle-plugin' }
        // 可选:保留官方源作为备用(如果镜像源缺失某些依赖)
        google()
        mavenCentral()
        jcenter()
    }
    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/central' }
        maven { url 'https://maven.aliyun.com/repository/jcenter' }
        maven { url 'https://maven.aliyun.com/repository/google' }
        maven { url 'https://maven.aliyun.com/repository/public' }
        maven { url 'https://maven.aliyun.com/repository/gradle-plugin' }
        maven { url 'https://www.jitpack.io' }
        // 可选:保留官方源作为备用(如果镜像源缺失某些依赖)
        google()
        mavenCentral()
        jcenter()
        maven {
            url 'https://api.mapbox.com/downloads/v2/releases/maven'
            authentication {
                basic(BasicAuthentication)
            }
            credentials {
                username = 'mapbox'
                password = project.properties['MAPBOX_DOWNLOADS_TOKEN'] ?: ""
            }
        }
    }
}

apply plugin: "com.facebook.react.rootproject"

之前一直安装报错,只有把package.json放出来

pack.json 

{
  "name": "AsProject",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "lint": "eslint .",
    "start": "react-native start",
    "test": "jest"
  },
  "dependencies": {
    "@dominicvonk/react-native-apk-installer": "^2.2.2",
    "@react-native-async-storage/async-storage": "^2.1.2",
    "@react-native-community/datetimepicker": "^8.3.0",
    "@react-native-community/geolocation": "^3.4.0",
    "@react-native-community/netinfo": "^11.4.1",
    "@react-native-community/progress-bar-android": "^1.0.5",
    "@react-native-picker/picker": "^2.11.0",
    "@react-navigation/bottom-tabs": "^7.2.0",
    "@react-navigation/elements": "^2.2.5",
    "@react-navigation/material-top-tabs": "^7.1.0",
    "@react-navigation/native": "^7.0.14",
    "@react-navigation/native-stack": "^7.2.0",
    "@reduxjs/toolkit": "^2.5.0",
    "@rnmapbox/maps": "^10.1.37",
    "@turf/turf": "^7.2.0",
    "axios": "^1.7.9",
    "crypto-js": "^4.2.0",
    "jsencrypt": "^3.3.2",
    "lodash": "^4.17.21",
    "lottie-ios": "^3.1.8",
    "lottie-react-native": "^7.2.2",
    "react": "18.3.1",
    "react-infinite-scroll-component": "^6.1.0",
    "react-native": "0.76.5",
    "react-native-config": "^1.5.5",
    "react-native-console-panel": "^0.1.0",
    "react-native-date-picker": "^5.0.10",
    "react-native-fs": "^2.20.0",
    "react-native-geolocation-service": "^5.3.1",
    "react-native-image-picker": "^8.1.0",
    "react-native-linear-gradient": "^2.8.3",
    "react-native-loading-spinner-overlay": "^3.0.1",
    "react-native-modal-datetime-picker": "^18.0.0",
    "react-native-pager-view": "^6.6.1",
    "react-native-paper": "^5.13.1",
    "react-native-permissions": "^5.2.6",
    "react-native-picker-select": "^9.3.1",
    "react-native-progress": "^5.0.1",
    "react-native-qrcode-scanner": "^1.5.5",
    "react-native-safe-area-context": "^5.0.0",
    "react-native-screens": "^4.4.0",
    "react-native-svg": "^15.11.2",
    "react-native-toast-message": "^2.2.1",
    "react-native-vector-icons": "^10.2.0",
    "react-native-video": "^6.10.2",
    "react-native-vision-camera": "^4.6.4",
    "react-native-vision-camera-face-detector": "^1.8.1",
    "react-native-vlc-media-player": "^1.0.78",
    "react-native-webrtc": "^124.0.5",
    "react-native-worklets-core": "^1.5.0",
    "react-redux": "^9.2.0"
  },
  "devDependencies": {
    "@babel/preset-env": "^7.25.3",
    "@babel/runtime": "^7.25.0",
    "@react-native-community/cli": "^15.0.1",
    "@react-native-community/cli-platform-android": "15.0.1",
    "@react-native-community/cli-platform-ios": "15.0.1",
    "@react-native/babel-preset": "0.76.5",
    "@react-native/eslint-config": "0.76.5",
    "@react-native/metro-config": "0.76.5",
    "@react-native/typescript-config": "0.76.5",
    "@types/jest": "^29.5.13",
    "@types/react": "^18.2.6",
    "@types/react-test-renderer": "^18.0.0",
    "cross-env": "^7.0.3",
    "eslint": "^8.19.0",
    "jest": "^29.6.3",
    "prettier": "2.8.8",
    "react-test-renderer": "18.3.1",
    "typescript": "5.0.4"
  },
  "engines": {
    "node": ">=18"
  }
}

你可能感兴趣的:(react,native,react.js,javascript)