编译flutter应用程序时出现错误

问题描述 投票:0回答:1

我正在尝试在android studio 3.5版本中运行我的flutter应用程序,但无法执行。我升级了flutter并重新安装了android studio。我使缓存无效并重新启动,但没有任何解决方案。我尝试使用Visual Studio代码,但遇到相同的错误。在下面,您可以看到我得到的错误。

有人知道如何解决吗?我的android studio之前运行良好,但不确定在更新后是否发生此问题。

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 resolve org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.50.
     Required by:
         project :
      > Could not resolve org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.50.
         > Could not get resource 'https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-gradle-plugin/1.3.50/kotlin-gradle-plugin-1.3.50.pom'.
            > Could not GET 'https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-gradle-plugin/1.3.50/kotlin-gradle-plugin-1.3.50.pom'.
               > Remote host closed connection during handshake
   > Could not resolve org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.41.
     Required by:
         project : > com.android.tools.build:gradle:3.5.0
         project : > com.android.tools.build:gradle:3.5.0 > com.android.tools.build:builder:3.5.0
         project : > com.android.tools.build:gradle:3.5.0 > com.android.tools.lint:lint-gradle-api:26.5.0
         project : > com.android.tools.build:gradle:3.5.0 > com.android.tools.build:gradle-api:3.5.0
         project : > com.android.tools.build:gradle:3.5.0 > androidx.databinding:databinding-compiler-common:3.5.0
         project : > com.android.tools.build:gradle:3.5.0 > com.android.tools.build:builder:3.5.0 > com.android.tools:sdk-common:26.5.0
         project : > com.android.tools.build:gradle:3.5.0 > com.android.tools.build:builder:3.5.0 > com.android.tools:common:26.5.0
         project : > com.android.tools.build:gradle:3.5.0 > com.android.tools.build:builder:3.5.0 > com.android.tools.build:manifest-merger:26.5.0
         project : > com.android.tools.build:gradle:3.5.0 > com.android.tools.build:builder:3.5.0 > com.android.tools.analytics-library:tracker:26.5.0
         project : > com.android.tools.build:gradle:3.5.0 > com.android.tools.build:builder:3.5.0 > com.android.tools:sdklib:26.5.0 > com.android.tools:repository:26.5.0
         project : > com.android.tools.build:gradle:3.5.0 > com.android.tools.build:builder:3.5.0 > com.android.tools:sdk-common:26.5.0 > com.android.tools.analytics-library:shared:26.5.0
      > Could not resolve org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.41.
         > Could not get resource 'https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-stdlib-jdk8/1.3.41/kotlin-stdlib-jdk8-1.3.41.pom'.
            > Could not GET 'https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-stdlib-jdk8/1.3.41/kotlin-stdlib-jdk8-1.3.41.pom'.
               > Remote host closed connection during handshake
   > Could not resolve org.ow2.asm:asm:6.0.
     Required by:
         project : > com.android.tools.build:gradle:3.5.0
         project : > com.android.tools.build:gradle:3.5.0 > com.android.tools.build:builder:3.5.0
         project : > com.android.tools.build:gradle:3.5.0 > com.android.tools.build.jetifier:jetifier-processor:1.0.0-beta04
      > Could not resolve org.ow2.asm:asm:6.0.
         > Could not get resource 'https://jcenter.bintray.com/org/ow2/asm/asm/6.0/asm-6.0.pom'.
            > Could not GET 'https://jcenter.bintray.com/org/ow2/asm/asm/6.0/asm-6.0.pom'.
               > Remote host closed connection during handshake
   > Could not resolve org.ow2.asm:asm-analysis:6.0.
     Required by:
         project : > com.android.tools.build:gradle:3.5.0
      > Could not resolve org.ow2.asm:asm-analysis:6.0.
         > Could not get resource 'https://jcenter.bintray.com/org/ow2/asm/asm-analysis/6.0/asm-analysis-6.0.pom'.
            > Could not GET 'https://jcenter.bintray.com/org/ow2/asm/asm-analysis/6.0/asm-analysis-6.0.pom'.
               > Remote host closed connection during handshake
   > Could not resolve org.ow2.asm:asm-commons:6.0.
     Required by:
         project : > com.android.tools.build:gradle:3.5.0
         project : > com.android.tools.build:gradle:3.5.0 > com.android.tools.build:builder:3.5.0
         project : > com.android.tools.build:gradle:3.5.0 > com.android.tools.build.jetifier:jetifier-processor:1.0.0-beta04
      > Could not resolve org.ow2.asm:asm-commons:6.0.
         > Could not get resource 'https://jcenter.bintray.com/org/ow2/asm/asm-commons/6.0/asm-commons-6.0.pom'.
            > Could not GET 'https://jcenter.bintray.com/org/ow2/asm/asm-commons/6.0/asm-commons-6.0.pom'.
               > Remote host closed connection during handshake
   > Could not resolve org.ow2.asm:asm-util:6.0.
     Required by:
         project : > com.android.tools.build:gradle:3.5.0
         project : > com.android.tools.build:gradle:3.5.0 > com.android.tools.build:builder:3.5.0
         project : > com.android.tools.build:gradle:3.5.0 > com.android.tools.build.jetifier:jetifier-processor:1.0.0-beta04
      > Could not resolve org.ow2.asm:asm-util:6.0.
         > Could not get resource 'https://jcenter.bintray.com/org/ow2/asm/asm-util/6.0/asm-util-6.0.pom'.
            > Could not GET 'https://jcenter.bintray.com/org/ow2/asm/asm-util/6.0/asm-util-6.0.pom'.
               > Remote host closed connection during handshake
   > Could not resolve net.sf.jopt-simple:jopt-simple:4.9.
     Required by:
         project : > com.android.tools.build:gradle:3.5.0
         project : > com.android.tools.build:gradle:3.5.0 > com.android.tools.build:builder:3.5.0
      > Could not resolve net.sf.jopt-simple:jopt-simple:4.9.
         > Could not get resource 'https://jcenter.bintray.com/net/sf/jopt-simple/jopt-simple/4.9/jopt-simple-4.9.pom'.
            > Could not GET 'https://jcenter.bintray.com/net/sf/jopt-simple/jopt-simple/4.9/jopt-simple-4.9.pom'.
               > Remote host closed connection during handshake

我的build.gradle是

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

    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

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
}


和app / 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.erod.xform_master"
        minSdkVersion 16
        targetSdkVersion 28
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    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 'androidx.test:runner:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
}

android-studio flutter
1个回答
0
投票

首先检查您的cmd中的flutter医生,看一切正常,然后,当您在android studio中创建新的flutter项目时,默认情况下不要使用kotlin或java作为lenguague,请不要标记任何在它们上,只是将它们留空

© www.soinside.com 2019 - 2024. All rights reserved.