我有一个分叉版本的React Native,它位于node_modules
。
但是,Android Studio仍在使用~/.gradle/caches
中的React Native安装。我知道这个,因为如果我做了一个导入,如:
import com.facebook.react.modules.core.DefaultHardwareBackBtnHandler;
然后我命令+点击它的最后一部分,它在~/.gradle/caches
实时打开的文件,它是一个非常旧版本的React Native(0.20.1)
如果我删除缓存并重建项目,则会自动下载相同的版本。
如何让Android Studio查看我的node_modules
目录而不是React Native的缓存目录?
在settings.gradle中:
...
include ':react-native-android'
project(':react-native-android').projectDir = new File(rootProject.projectDir, '../node_modules/react-native/ReactAndroid')
在app / build.gradle中
...
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:23.0.1'
compile project(':react-native-android')
}
configurations.all {
exclude group: 'com.facebook.react', module: 'react-native'
}
在build.gradle中:
buildscript {
repositories {
jcenter()
maven {
url "$rootDir/../node_modules/react-native/android"
}
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
classpath 'de.undercouch:gradle-download-task:3.1.2'
}
}
allprojects {
repositories {
mavenLocal()
jcenter()
maven {
url "$rootDir/../node_modules/react-native/android"
}
}
}
答案 0 :(得分:1)
好的,这是有帮助的:
./gradlew :ReactAndroid:assembleDebug
然后:
./gradlew :ReactAndroid:installArchives
来源:
https://github.com/Microsoft/react-native-code-push/issues/858
https://github.com/uk-ar/react-native/tree/master/ReactAndroid