在React Native

时间:2018-10-24 14:35:47

标签: android android-studio react-native android-gradle

我试图在Android Studio中同步React-Native项目,每当我尝试同步它时,都会引发如下错误,

Could not find intellij-core.jar (com.android.tools.external.com-intellij:intellij-core:26.0.1).
Searched in the following locations:
    https://jcenter.bintray.com/com/android/tools/external/com-intellij/intellij-core/26.0.1/intellij-core-26.0.1.jaa r

我为Cordova和其他项目尝试了前面提到的许多方法来解决同一问题,但是我看不到它对我的React-Native有用。

我的build.gradle文件如下所示

buildscript {
    ext {
        buildToolsVersion = "27.0.3"
        minSdkVersion = 16
        compileSdkVersion = 27
        targetSdkVersion = 26
        supportLibVersion = "27.1.1"
    }
    repositories {
        jcenter()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.4'

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

allprojects {
    repositories {
        mavenLocal()
        jcenter()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url "$rootDir/../node_modules/react-native/android"
        }
        google()
    }
}

重复问题的答案看起来像是科尔多瓦,但是我的问题将要用React-Native进行,我尝试了所有答案,但都没有用

2 个答案:

答案 0 :(得分:0)

看来jcenter昨天坏了。在您的build.gradle文件中,将jcenter()移到google()下方(两个位置)。

有关更多信息: https://github.com/facebook/react-native/issues/21907#issuecomment-432319128

答案 1 :(得分:0)

在android / CordovaLib /build.gradle

下进行此特定更改
repositories {maven {
url "https://maven.google.com"} jcenter()}

注意:在maven之后添加jcenter()并使用cordova 平台添加android@7.1.1 来添加platfrom