【问题标题】:Unexpected token in \android\build.gradle line: 12 : unexpected token: }\android\build.gradle 行中的意外令牌:12:意外令牌:}
【发布时间】:2020-12-17 12:15:20
【问题描述】:

我正在尝试使用 react-native 运行一个项目。

我遵循了Viro's website.中给出的所有步骤

当尝试使用react-native run-android 构建项目时,我收到以下错误:

Could not compile build file '\ARDemo\android\build.gradle'.

启动失败: 构建文件 '\ARDemo\android\build.gradle':12:意外令牌:} @ 第 12 行,第 1 列。 } ^

1 个错误

  • 尝试: 使用 --stacktrace 选项运行以获取堆栈跟踪。使用 --info 或 --debug 选项运行以获得更多日志输出。运行 --scan 以获得完整的见解。

  • 通过https://help.gradle.org获得更多帮助

8 秒后构建失败

错误安装失败

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

buildscript {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.0'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
} // --> error is detected in this line

allprojects {
    // Workaround for https://issuetracker.google.com/117900475
    // Remove when upgrading to AGP 3.4 or higher
    configurations.matching { it.name == '_internal_aapt2_binary' }.all { config ->
    config.resolutionStrategy.eachDependency { details ->
        details.useVersion("3.5.0-alpha03-5252756")
    }
}
repositories {
    mavenLocal()
    maven {
        url 'https://maven.google.com/'
    }
    maven {
        // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
        url("$rootDir/../node_modules/react-native/android")
    google()
    jcenter()
    maven { url 'https://www.jitpack.io' }
}

}

【问题讨论】:

  • 您好像放了多余的大括号或忘记添加了

标签: android react-native gradle virtual-reality


【解决方案1】:

buildscript { 之后你又错过了repositories {

试试这个:

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

buildscript {
    repositories { // --> this was missing
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.0'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
} 

allprojects {
    // Workaround for https://issuetracker.google.com/117900475
    // Remove when upgrading to AGP 3.4 or higher
    configurations.matching { it.name == '_internal_aapt2_binary' }.all { config ->
        config.resolutionStrategy.eachDependency { details ->
            details.useVersion("3.5.0-alpha03-5252756")
        }
    }
    repositories {
        mavenLocal()
        maven {
            url 'https://maven.google.com/'
        }
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url("$rootDir/../node_modules/react-native/android")
            google()
            jcenter()
            maven { url 'https://www.jitpack.io' }
        }
    }
}

【讨论】:

  • 试过这个。没有帮助?
  • 所以你在添加repositories { 行后仍然得到同样的错误?还是变了?
猜你喜欢
  • 1970-01-01
  • 2021-03-19
  • 1970-01-01
  • 2019-08-06
  • 2014-11-29
  • 2018-11-19
  • 2017-04-17
  • 2019-05-26
  • 2014-02-19
相关资源
最近更新 更多