Reputation: 32061
I have a forked version of React Native that lives in node_modules
.
However, Android Studio is still using the React Native installation found in ~/.gradle/caches
. I know this because if I do an import like:
import com.facebook.react.modules.core.DefaultHardwareBackBtnHandler;
and I command+click on the last part of it, the file it opens live in ~/.gradle/caches
, and it's a very old version of React Native (0.20.1)
If I delete the cache, and rebuild the project, the same version is downloaded automatically.
How can I get Android Studio to look in my node_modules
directory and not the cached directory for React Native?
In settings.gradle:
...
include ':react-native-android'
project(':react-native-android').projectDir = new File(rootProject.projectDir, '../node_modules/react-native/ReactAndroid')
In 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'
}
In 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"
}
}
}
Upvotes: 0
Views: 1460
Reputation: 32061
Ok, here's what helped:
./gradlew :ReactAndroid:assembleDebug
Then:
./gradlew :ReactAndroid:installArchives
Sources:
https://github.com/Microsoft/react-native-code-push/issues/858
https://github.com/uk-ar/react-native/tree/master/ReactAndroid
Upvotes: 1