Can';t构建android项目

Can';t构建android项目,android,react-native,gradle,Android,React Native,Gradle,我用的是react native。我的项目运作良好,但几个月后我不得不对我的项目进行一些修改。现在,我正在尝试使用react native run android构建项目,它抛出了一个异常 我搜索了这个问题,所有的解决方案都是edit build.gradle和addgoogle() 例外情况: FAILURE: Build failed with an exception. * What went wrong: A problem occurred configuring root proj

我用的是react native。我的项目运作良好,但几个月后我不得不对我的项目进行一些修改。现在,我正在尝试使用
react native run android
构建项目,它抛出了一个异常

我搜索了这个问题,所有的解决方案都是edit build.gradle和add
google()

例外情况:

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'project'.
> Could not resolve all artifacts for configuration ':classpath'.
   > Could not find gradle.jar (com.android.tools.build:gradle:3.2.1).
     Searched in the following locations:
         https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.2.1/gradle-3.2.1.jar
   > Could not find builder.jar (com.android.tools.build:builder:3.2.1).
     Searched in the following locations:
         https://dl.google.com/dl/android/maven2/com/android/tools/build/builder/3.2.1/builder-3.2.1.jar
   > Could not find tracker.jar (com.android.tools.analytics-library:tracker:26.2.1).
     Searched in the following locations:
         https://dl.google.com/dl/android/maven2/com/android/tools/analytics-library/tracker/26.2.1/tracker-26.2.1.jar
   > Could not find shared.jar (com.android.tools.analytics-library:shared:26.2.1).
     Searched in the following locations:
         https://dl.google.com/dl/android/maven2/com/android/tools/analytics-library/shared/26.2.1/shared-26.2.1.jar
   > Could not find crash.jar (com.android.tools.analytics-library:crash:26.2.1).
     Searched in the following locations:
         https://dl.google.com/dl/android/maven2/com/android/tools/analytics-library/crash/26.2.1/crash-26.2.1.jar
   > Could not find lint-gradle-api.jar (com.android.tools.lint:lint-gradle-api:26.2.1).
     Searched in the following locations:
         https://dl.google.com/dl/android/maven2/com/android/tools/lint/lint-gradle-api/26.2.1/lint-gradle-api-26.2.1.jar
   > Could not find gradle-api.jar (com.android.tools.build:gradle-api:3.2.1).
     Searched in the following locations:
         https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle-api/3.2.1/gradle-api-3.2.1.jar
   > Could not find databinding-compiler-common.jar (androidx.databinding:databinding-compiler-common:3.2.1).
     Searched in the following locations:
         https://dl.google.com/dl/android/maven2/androidx/databinding/databinding-compiler-common/3.2.1/databinding-compiler-common-3.2.1.jar
   > Could not find manifest-merger.jar (com.android.tools.build:manifest-merger:26.2.1).
     Searched in the following locations:
         https://dl.google.com/dl/android/maven2/com/android/tools/build/manifest-merger/26.2.1/manifest-merger-26.2.1.jar
   > Could not find sdk-common.jar (com.android.tools:sdk-common:26.2.1).
     Searched in the following locations:
         https://dl.google.com/dl/android/maven2/com/android/tools/sdk-common/26.2.1/sdk-common-26.2.1.jar
   > Could not find builder-test-api.jar (com.android.tools.build:builder-test-api:3.2.1).
     Searched in the following locations:
         https://dl.google.com/dl/android/maven2/com/android/tools/build/builder-test-api/3.2.1/builder-test-api-3.2.1.jar
   > Could not find ddmlib.jar (com.android.tools.ddms:ddmlib:26.2.1).
     Searched in the following locations:
         https://dl.google.com/dl/android/maven2/com/android/tools/ddms/ddmlib/26.2.1/ddmlib-26.2.1.jar
   > Could not find sdklib.jar (com.android.tools:sdklib:26.2.1).
     Searched in the following locations:
         https://dl.google.com/dl/android/maven2/com/android/tools/sdklib/26.2.1/sdklib-26.2.1.jar
   > Could not find layoutlib-api.jar (com.android.tools.layoutlib:layoutlib-api:26.2.1).
     Searched in the following locations:
         https://dl.google.com/dl/android/maven2/com/android/tools/layoutlib/layoutlib-api/26.2.1/layoutlib-api-26.2.1.jar
   > Could not find dvlib.jar (com.android.tools:dvlib:26.2.1).
     Searched in the following locations:
         https://dl.google.com/dl/android/maven2/com/android/tools/dvlib/26.2.1/dvlib-26.2.1.jar
   > Could not find repository.jar (com.android.tools:repository:26.2.1).
     Searched in the following locations:
         https://dl.google.com/dl/android/maven2/com/android/tools/repository/26.2.1/repository-26.2.1.jar
   > Could not find common.jar (com.android.tools:common:26.2.1).
     Searched in the following locations:
         https://dl.google.com/dl/android/maven2/com/android/tools/common/26.2.1/common-26.2.1.jar
   > Could not find jetifier-processor.jar (com.android.tools.build.jetifier:jetifier-processor:1.0.0-alpha10).
     Searched in the following locations:
         https://dl.google.com/dl/android/maven2/com/android/tools/build/jetifier/jetifier-processor/1.0.0-alpha10/jetifier-processor-1.0.0-alpha10.jar
   > Could not find bundletool.jar (com.android.tools.build:bundletool:0.5.0).
     Searched in the following locations:
         https://dl.google.com/dl/android/maven2/com/android/tools/build/bundletool/0.5.0/bundletool-0.5.0.jar
   > Could not find jetifier-core.jar (com.android.tools.build.jetifier:jetifier-core:1.0.0-alpha10).
     Searched in the following locations:
         https://dl.google.com/dl/android/maven2/com/android/tools/build/jetifier/jetifier-core/1.0.0-alpha10/jetifier-core-1.0.0-alpha10.jar
   > Could not find builder-model.jar (com.android.tools.build:builder-model:3.2.1).
     Searched in the following locations:
         https://dl.google.com/dl/android/maven2/com/android/tools/build/builder-model/3.2.1/builder-model-3.2.1.jar
   > Could not find protos.jar (com.android.tools.analytics-library:protos:26.2.1).
     Searched in the following locations:
         https://dl.google.com/dl/android/maven2/com/android/tools/analytics-library/protos/26.2.1/protos-26.2.1.jar
   > Could not find apkzlib.jar (com.android.tools.build:apkzlib:3.2.1).
     Searched in the following locations:
         https://dl.google.com/dl/android/maven2/com/android/tools/build/apkzlib/3.2.1/apkzlib-3.2.1.jar
   > Could not find apksig.jar (com.android.tools.build:apksig:3.2.1).
     Searched in the following locations:
         https://dl.google.com/dl/android/maven2/com/android/tools/build/apksig/3.2.1/apksig-3.2.1.jar
   > Could not find annotations.jar (com.android.tools:annotations:26.2.1).
     Searched in the following locations:
         https://dl.google.com/dl/android/maven2/com/android/tools/annotations/26.2.1/annotations-26.2.1.jar
   > Could not find databinding-common.jar (androidx.databinding:databinding-common:3.2.1).
     Searched in the following locations:
         https://dl.google.com/dl/android/maven2/androidx/databinding/databinding-common/3.2.1/databinding-common-3.2.1.jar
   > Could not find baseLibrary.jar (com.android.databinding:baseLibrary:3.2.1).
     Searched in the following locations:
         https://dl.google.com/dl/android/maven2/com/android/databinding/baseLibrary/3.2.1/baseLibrary-3.2.1.jar

* 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 3s
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/getting-started.html

Command failed: gradlew.bat installDebug

Error: Command failed: gradlew.bat installDebug
    at checkExecSyncError (child_process.js:616:11)
    at Object.execFileSync (child_process.js:634:13)
    at runOnAllDevices (F:\clone\Remote_Device_Controller\node_modules\react-native\local-cli\runAndroid\runAndroid.js:299:19)
    at buildAndRun (F:\clone\Remote_Device_Controller\node_modules\react-native\local-cli\runAndroid\runAndroid.js:135:12)
    at isPackagerRunning.then.result (F:\clone\Remote_Device_Controller\node_modules\react-native\local-cli\runAndroid\runAndroid.js:65:12)
    at process._tickCallback (internal/process/next_tick.js:68:7)
build.gradle存储库:

buildscript {
    ext {
        buildToolsVersion = "28.0.2"
        minSdkVersion = 16
        compileSdkVersion = 28
        targetSdkVersion = 27
        supportLibVersion = "28.0.0"
    }
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'

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

allprojects {
    repositories {
        mavenLocal()
        google()
        jcenter()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url "$rootDir/../node_modules/react-native/android"
        }
    }
}
有人知道我的项目发生了什么吗?上次我成功构建项目时,我甚至连一条线都没有碰到


顺便说一句,这是如此奇怪的链接,说找不到是工作得很好,我复制并粘贴在我的浏览器。它可以手动下载,您应该首先从项目目录导航到android文件夹,然后从命令行运行clean项目命令:./gradlew clean。并导航回项目文件夹,然后再次尝试运行。另外,请尝试增加gradle wrapper的版本,您可以在gradle文件夹->gradle wrapper.properties中找到该版本。@mmmate尝试gradlew Clean时出现相同错误您是否同时更改了Android Studio或gradle的版本?无论如何,您可能希望尝试“使缓存无效并重新启动”。此外,有时关闭项目,将其从AS的项目列表中删除,然后再次导入有助于解决奇怪的问题。@Amas尝试将“com.android.tools.build:gradle:”版本更改为最新版本,例如,将其更改为3.3.1版,同时将targetSdkVersion=28,而不是27。