簡體   English   中英

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

apple@mosesdeMacBook-Pro:~/Desktop/sxtbdemo2$ react-native run-android
Scanning folders for symlinks in /Users/apple/Desktop/sxtbdemo2/node_modules (8ms)
JS server already running.
Building and installing the app on the device (cd android && ./gradlew installDebug)...

FAILURE: Build failed with an exception.

What went wrong:
A problem occurred configuring root project 'sxtbdemo2'.
Could not resolve all files for configuration ':classpath'.
Could not find com.android.tools.build:gradle:3.0.1.
 Searched in the following locations:
     https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.pom
     https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.jar
 Required by:
     project :

 Try:
     Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Get more help at https://help.gradle.org

BUILD FAILED in 12s
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have set up your Android development environment: https://facebook.github.io/react-native/docs/android-setup.html

gradle文件中的存儲庫通常是一個問題。

對我來說,這樣修改了build.gradle:

buildscript {
    repositories {
        mavenLocal()
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'
    }
}

因此,當您添加google()時,它應該可以工作。

buildscript {
    repositories {
        jcenter()
        google()
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'      
    }
}

buildscript()和Sync Project中添加google()

參考: https : //developer.android.com/studio/build/gradle-plugin-3-0-0-migration.html#apply_plugin

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM