简体   繁体   English

运行 react-native run-android 时出错:build.gradle 中的意外令牌

[英]Error running react-native run-android: Unexpected Token in build.gradle

What went wrong: Could not compile build file '/Users/nathanael/Code/highst/mobile/android/build.gradle'.出了什么问题:无法编译构建文件“/Users/nathanael/Code/highst/mobile/android/build.gradle”。

startup failed: build file '/../../android/build.gradle': 6: unexpected token: << @ line 6, column 1.启动失败:构建文件“/../../android/build.gradle”:6:意外标记:<<@第 6 行,第 1 列。

 <<<<<<< ours ^ 1 error

Sorry in advance, I'm a Gradle noob.提前抱歉,我是 Gradle 菜鸟。 I'm having this issue whenever I run react-native run-android每当我运行 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

it is saying that <<<<< is not recognizable syntax by gradle.据说 <<<<< 是 gradle 无法识别的语法。 your project has git merge conflict you should either accept theirs or ours and delete <<<<< parts您的项目存在 git 合并冲突,您应该接受他们的或我们的并删除<<<<<部分

Either you should fetch fresh code from repo or delete "theirs" section and keep "ours" section as a suggestion.您应该从 repo 中获取新代码或删除“他们的”部分并保留“我们的”部分作为建议。

However seeing both the sections, from my experience: ext variables and class dependencies from theirs should move to project level build.gradle file.但是,根据我的经验,看到这两个部分:来自theirs ext 变量和类依赖项应该移动到项目级别的 build.gradle 文件。

Clearly, "ours" section is from '<<<<<' till '=====' and 'theirs' section is from '=====' till '>>>>>'.显然,“我们的”部分是从 '<<<<<' 到 '=====' 而 'theirs' 部分是从 '=====' 到 '>>>>>'。

Please see:请参见:

Basic Git Commands 基本 Git 命令

Learn GIT with BitBucket 通过 BitBucket 学习 GIT

How to resolve merge conflicts in Git如何解决 Git 中的合并冲突

Resolving a merge conflict using the command line 使用命令行解决合并冲突

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 react-native运行Android构建由于错误而失败 - react-native run-android build failing because of error 在Ubuntu 14上运行“ react-native run-android”时出错 - Error Running 'react-native run-android' on ubuntu 14 运行 `react-native run-android` 时出错 - Getting error while running `react-native run-android` 此版本中使用了已弃用的 Gradle 功能,使其与 Gradle 7.0 不兼容。 运行react-native时运行-android - Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0. When running react-native run-android 运行 npx react-native run-android 命令时出现 React-native android 错误 - React-native android error when running the npx react-native run-android command 使用 react-native run-android 运行时出现 React-Native 错误 - React-Native error when running with react-native run-android Gradle 在尝试使用 run-android 命令运行 react-native 项目时出现构建问题 - Gradle Build issue while trying to run a react-native project using run-android command react-native运行android找不到com.android.tools.build:gradle:3.0.1 - react-native run-android Could not find com.android.tools.build:gradle:3.0.1 无法解析com.android.tools.build:gradle:3.1.4,react-native run-android - Could not resolve com.android.tools.build:gradle:3.1.4, react-native run-android react-native run-android 在删除 Gradle 目录时冻结 - react-native run-android freezes on deleting Gradle directory
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM