I am trying to run a project using react-native.
I followed all the steps given in Viro's website.
When trying to build the project using react-native run-android
, I however get the following error:
Could not compile build file '\ARDemo\android\build.gradle'.
startup failed: build file '\ARDemo\android\build.gradle': 12: unexpected token: } @ line 12, column 1. } ^
1 error
Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Get more help at https://help.gradle.org
BUILD FAILED in 8s
error Failed to install
// 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' }
}
}
You're missing repositories {
after buildscript {
Try this:
// 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' }
}
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.