颤振问题:“无法解决配置':classpath'的所有工件" [英] Flutter problems: "Could not resolve all artifacts for configuration ':classpath' "

查看:116
本文介绍了颤振问题:“无法解决配置':classpath'的所有工件"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试运行在设备上编写的Flutter应用程序,但是当我尝试运行该应用程序时,我从不经过"assembleDebug"阶段并在终端中收到以下消息:

I am trying to run a flutter app I am writing on my device but when I try to run, I never get past the "assembleDebug" stage and get this message in the terminal:

Launching lib\main.dart on SM N950U in debug mode...
Running Gradle task 'assembleDebug'...

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'android'.
> Could not resolve all artifacts for configuration ':classpath'.
   > Could not find com.android.tools.build:gradle:5.6.2.
     Searched in the following locations:
       - https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/5.6.2/gradle-5.6.2.pom
       - https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/5.6.2/gradle-5.6.2.jar
       - https://jcenter.bintray.com/com/android/tools/build/gradle/5.6.2/gradle-5.6.2.pom
       - https://jcenter.bintray.com/com/android/tools/build/gradle/5.6.2/gradle-5.6.2.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. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 14s
Finished with error: Gradle task assembleDebug failed with exit code 1

我最近已更新到gradle 6.0.1(我假设我正确地做到了,但是我对这一切还是很陌生的),并且flutter Doctor没问题.

I have recently updated to gradle 6.0.1 (I assume I did that correctly but I am very new to all this) and there are no issues with flutter doctor.

这是我的项目级别build.gradle:

Here is my project level build.gradle:

buildscript {
    ext.kotlin_version = '1.3.50'
    repositories {
        google()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:5.6.2'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.google.gms:google-services:4.3.3'
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

rootProject.buildDir = '../build'
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
    project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

这是应用程序级别的build.gradle:

Here is the app level build.gradle:

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
    localPropertiesFile.withReader('UTF-8') { reader ->
        localProperties.load(reader)
    }
}

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
    throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
    flutterVersionCode = '1'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
    flutterVersionName = '1.0'
}

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
    compileSdkVersion 28

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }

    lintOptions {
        disable 'InvalidPackage'
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.example.skypeclone1"
        minSdkVersion 16
        targetSdkVersion 28
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
    }

    buildTypes {
        release {
            // TODO: Add your own signing config for the release build.
            // Signing with the debug keys for now, so `flutter run --release` works.
            signingConfig signingConfigs.debug
        }
    }
}

flutter {
    source '../..'
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
apply plugin: 'com.google.gms.google-services'

这是我的Gradle包装器属性,以防它们也很重要.

Here are my Gradle wrapper properties in case they are also important.

#Fri Jun 23 08:50:38 CEST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip

gradle.properties

gradle.properties

org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true
android.enableJetifier=true
android.enableR8=true

推荐答案

您正在尝试使用实际的Gradle.对于Android开发,本月发布了当前版本为3.5.3的Android Gradle.阅读本文: https://developer.android.com/studio /releases/gradle-plugin#3-5-0 .

You're trying to use actual Gradle. For Android development, there's Android Gradle which is currently on version 3.5.3 which came out this month. Read this article: https://developer.android.com/studio/releases/gradle-plugin#3-5-0.

要使用最新版本的Android Gradle(3.5.3),您需要的5.4.1-5.6.4之间的Gradle版本可以在gradle-wrapper.properties文件中进行配置.我猜Android Gradle尚不支持Gradle 6.

To use the latest version of Android Gradle (3.5.3), you need Gradle versions between 5.4.1-5.6.4 which you can configure in the gradle-wrapper.properties file. I guess Android Gradle doesn't yet support Gradle 6.

这篇关于颤振问题:“无法解决配置':classpath'的所有工件"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆