【问题标题】:Android Studio is using Gradle cached version of React-NativeAndroid Studio 正在使用 Gradle 缓存版本的 React-Native
【发布时间】:2017-09-18 23:45:30
【问题描述】:

我有一个分支版本的 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"
        }
    }
}

【问题讨论】:

    标签: android android-studio react-native


    【解决方案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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-04-08
      • 2018-12-25
      • 1970-01-01
      • 2022-08-22
      • 2018-12-30
      • 2016-06-22
      相关资源
      最近更新 更多