首页 > 解决方案 > 错误运行 react-native run-android: Unexpected Token in build.gradle

问题描述

出了什么问题:无法编译构建文件'/Users/nathanael/Code/highst/mobile/android/build.gradle'。

启动失败:构建文件'/../../android/build.gradle':6:意外令牌:<<@第6行,第1列。

 <<<<<<< ours
 ^
 1 error

提前抱歉,我是一个 Gradle 菜鸟。每当我运行 react-native run-android 时都会遇到这个问题

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

    buildscript {
    repositories {
        jcenter()
    <<<<<<< ours
        maven { url 'https://maven.fabric.io/public' }
        mavenCentral()



    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.3'
        classpath 'com.google.gms:google-services:3.1.2'
        classpath 'io.fabric.tools:gradle:1.+'
=======
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.3'
>>>>>>> theirs

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

allprojects {
    repositories {
        mavenLocal()
        mavenCentral()

        jcenter()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url "$rootDir/../node_modules/react-native/android"
        }
        maven {
<<<<<<< ours
            url 'https://maven.google.com'
        }
    }
    }

=======
            url 'https://maven.google.com/'
            name 'Google'
        }
    }
}

ext {
    buildToolsVersion = "26.0.3"
    minSdkVersion = 16
    compileSdkVersion = 26
    targetSdkVersion = 26
    supportLibVersion = "26.1.0"
}
>>>>>>> theirs

标签: androidgitreact-nativereact-native-androidmerge-conflict-resolution

解决方案


据说 <<<<< 不是 gradle 可识别的语法。您的项目有 git 合并冲突,您应该接受他们的或我们的并删除<<<<<部分


推荐阅读