ReactNative项目把Android/ios/react剥离出来独立模块

项目结构

ReactNative项目把Android/ios/react剥离出来独立模块_第1张图片

Android native部分

ReactNative项目把Android/ios/react剥离出来独立模块_第2张图片

react部分

ReactNative项目把Android/ios/react剥离出来独立模块_第3张图片

Android Native 配置node_modules目录

local.properties配置

sdk.dir=E\:\\Android\\Sdk
react.path=E\:\\ReactNative\\MyReactNativeApp\\react

settings.gradle配置

include ':react-native-gesture-handler', ':common-silent', ':appservice', ':senseid-liveness-silent-offline', ':appcore'
logger.info(rootDir.path)
File file = new File(rootDir.path,"local.properties")
println file.path
Properties mp = new Properties()
mp.load(new FileInputStream(file))
include ':react-native-gesture-handler'
project(':react-native-gesture-handler').projectDir = new File(mp.getProperty("react.path"), '\\node_modules\\react-native-gesture-handler\\android')
include ':app'

build.gradle配置

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext.kotlin_version = '1.3.40'
    ext.kotlin_version = '1.3.31'
    ext.kotlin_version = '1.2.71'
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

def loadLocalProp() {
    File file = rootProject.file("local.properties")
    if (file.exists()) {
        Properties mp = new Properties()
        mp.load(rootProject.file("local.properties").newDataInputStream())
        def local = [:]
        mp.keySet().each {
            local[it] = mp.getProperty(it.toString())
        }
        return local
    }
}
def local = loadLocalProp()

allprojects {
    repositories {
        google()
        jcenter()
        maven {
            // All of React Native (JS, Android binaries) is installed from npm
            url "${local['react.path']}/node_modules/react-native/android"
        }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

在react目录下 yarn install yarn start

你可能感兴趣的:(androidstudio,ReactNative,Kotlin编程语言)