簡體   English   中英

無法在模擬器上運行 flutter 項目

[英]Cannot run flutter project on emulator

我已經下載了 Android Studio Chipmunk|2021.2.1 補丁 1
我有 java 版本 8(構建 1.8.0_341-b10)
我正在嘗試在 vscode 上運行 main.dart (默認 flutter 程序),但它不起作用\

我已經運行 flutter 醫生命令來檢查任何問題,但一切都是正確的在此處輸入圖像描述

錯誤列表是:

FAILURE: Build failed with an exception.

* Where:
Build file 'G:\proj\android\app\build.gradle' line: 26

* What went wrong:
A problem occurred evaluating project ':app'.
> Could not resolve all files for configuration 'classpath'.
   > Could not resolve org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.72.
     Required by:
         unspecified:unspecified:unspecified > com.android.tools.build:gradle:4.1.0
         unspecified:unspecified:unspecified > com.android.tools.build:gradle:4.1.0 > com.android.tools.build:builder:4.1.0
         unspecified:unspecified:unspecified > com.android.tools.build:gradle:4.1.0 > com.android.tools.build:aaptcompiler:4.1.0
         unspecified:unspecified:unspecified > com.android.tools.build:gradle:4.1.0 > com.android.tools.lint:lint-gradle-api:27.1.0
         unspecified:unspecified:unspecified > com.android.tools.build:gradle:4.1.0 > com.android.tools.build:gradle-api:4.1.0
         unspecified:unspecified:unspecified > com.android.tools.build:gradle:4.1.0 > androidx.databinding:databinding-compiler-common:4.1.0
         unspecified:unspecified:unspecified > com.android.tools.build:gradle:4.1.0 > com.android.tools.build:builder:4.1.0 > com.android.tools.build:builder-model:4.1.0
         unspecified:unspecified:unspecified > com.android.tools.build:gradle:4.1.0 > com.android.tools.build:builder:4.1.0 > com.android.tools:sdk-common:27.1.0
         unspecified:unspecified:unspecified > com.android.tools.build:gradle:4.1.0 > com.android.tools.build:builder:4.1.0 > com.android.tools:common:27.1.0
         unspecified:unspecified:unspecified > com.android.tools.build:gradle:4.1.0 > com.android.tools.build:builder:4.1.0 > com.android.tools.build:manifest-merger:27.1.0
         unspecified:unspecified:unspecified > com.android.tools.build:gradle:4.1.0 > com.android.tools.build:builder:4.1.0 > com.android.tools.analytics-library:tracker:27.1.0
         unspecified:unspecified:unspecified > com.android.tools.build:gradle:4.1.0 > com.android.tools.lint:lint-gradle-api:27.1.0 > com.android.tools.lint:lint-model:27.1.0
         unspecified:unspecified:unspecified > com.android.tools.build:gradle:4.1.0 > com.android.tools.build:builder:4.1.0 > com.android.tools:sdklib:27.1.0 > com.android.tools:repository:27.1.0
         unspecified:unspecified:unspecified > com.android.tools.build:gradle:4.1.0 > com.android.tools.build:builder:4.1.0 > com.android.tools:sdk-common:27.1.0 > com.android.tools.analytics-library:shared:27.1.0
      > Could not resolve org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.72.
         > Could not get resource 'https://repo.maven.apache.org/maven2/org/jetbrains/kotlin/kotlin-stdlib-jdk8/1.3.72/kotlin-stdlib-jdk8-1.3.72.pom'.
            > Could not GET 'https://repo.maven.apache.org/maven2/org/jetbrains/kotlin/kotlin-stdlib-jdk8/1.3.72/kotlin-stdlib-jdk8-1.3.72.pom'.
               > The server may not support the client's requested TLS protocol versions: (TLSv1.2, TLSv1.3). You may need to configure the client to allow other protocols to be used. See: https://docs.gradle.org/7.4/userguide/build_environment.html#gradle_system_properties
                  > Remote host terminated the handshake
   > Could not resolve org.ow2.asm:asm:7.0.
     Required by:
         unspecified:unspecified:unspecified > com.android.tools.build:gradle:4.1.0
         unspecified:unspecified:unspecified > com.android.tools.build:gradle:4.1.0 > com.android.tools.build:builder:4.1.0
      > Could not resolve org.ow2.asm:asm:7.0.
         > Could not get resource 'https://repo.maven.apache.org/maven2/org/ow2/asm/asm/7.0/asm-7.0.pom'.
            > Could not GET 'https://repo.maven.apache.org/maven2/org/ow2/asm/asm/7.0/asm-7.0.pom'.
               > The server may not support the client's requested TLS protocol versions: (TLSv1.2, TLSv1.3). You may need to configure the client to allow other protocols to be used. See: https://docs.gradle.org/7.4/userguide/build_environment.html#gradle_system_properties
                  > Remote host terminated the handshake
   > Could not resolve org.ow2.asm:asm-analysis:7.0.
     Required by:
         unspecified:unspecified:unspecified > com.android.tools.build:gradle:4.1.0
      > Could not resolve org.ow2.asm:asm-analysis:7.0.
         > Could not get resource 'https://repo.maven.apache.org/maven2/org/ow2/asm/asm-analysis/7.0/asm-analysis-7.0.pom'.
            > Could not GET 'https://repo.maven.apache.org/maven2/org/ow2/asm/asm-analysis/7.0/asm-analysis-7.0.pom'.
               > The server may not support the client's requested TLS protocol versions: (TLSv1.2, TLSv1.3). You may need to configure the client to allow other protocols to be used. See: https://docs.gradle.org/7.4/userguide/build_environment.html#gradle_system_properties
                  > Remote host terminated the handshake
   > Could not resolve org.ow2.asm:asm-commons:7.0.
     Required by:
         unspecified:unspecified:unspecified > com.android.tools.build:gradle:4.1.0
         unspecified:unspecified:unspecified > com.android.tools.build:gradle:4.1.0 > com.android.tools.build:builder:4.1.0
      > Could not resolve org.ow2.asm:asm-commons:7.0.
         > Could not get resource 'https://repo.maven.apache.org/maven2/org/ow2/asm/asm-commons/7.0/asm-commons-7.0.pom'.
            > Could not GET 'https://repo.maven.apache.org/maven2/org/ow2/asm/asm-commons/7.0/asm-commons-7.0.pom'.
               > The server may not support the client's requested TLS protocol versions: (TLSv1.2, TLSv1.3). You may need to configure the client to allow other protocols to be used. See: https://docs.gradle.org/7.4/userguide/build_environment.html#gradle_system_properties
                  > Remote host terminated the handshake
   > Could not resolve org.ow2.asm:asm-util:7.0.
     Required by:
         unspecified:unspecified:unspecified > com.android.tools.build:gradle:4.1.0
         unspecified:unspecified:unspecified > com.android.tools.build:gradle:4.1.0 > com.android.tools.build:builder:4.1.0
      > Could not resolve org.ow2.asm:asm-util:7.0.
         > Could not get resource 'https://repo.maven.apache.org/maven2/org/ow2/asm/asm-util/7.0/asm-util-7.0.pom'.
            > Could not GET 'https://repo.maven.apache.org/maven2/org/ow2/asm/asm-util/7.0/asm-util-7.0.pom'.
               > The server may not support the client's requested TLS protocol versions: (TLSv1.2, TLSv1.3). You may need to configure the client to allow other protocols to be used. See: https://docs.gradle.org/7.4/userguide/build_environment.html#gradle_system_properties
                  > Remote host terminated the handshake
   > Could not resolve net.sf.proguard:proguard-gradle:6.0.3.
     Required by:
         unspecified:unspecified:unspecified > com.android.tools.build:gradle:4.1.0
      > Could not resolve net.sf.proguard:proguard-gradle:6.0.3.
         > Could not get resource 'https://repo.maven.apache.org/maven2/net/sf/proguard/proguard-gradle/6.0.3/proguard-gradle-6.0.3.pom'.
            > Could not GET 'https://repo.maven.apache.org/maven2/net/sf/proguard/proguard-gradle/6.0.3/proguard-gradle-6.0.3.pom'.
               > The server may not support the client's requested TLS protocol versions: (TLSv1.2, TLSv1.3). You may need to configure the client to allow other protocols to be used. See: https://docs.gradle.org/7.4/userguide/build_environment.html#gradle_system_properties
                  > Remote host terminated the handshake
   > Could not resolve org.tensorflow:tensorflow-lite-metadata:0.1.0-rc1.
     Required by:
         unspecified:unspecified:unspecified > com.android.tools.build:gradle:4.1.0
      > Could not resolve org.tensorflow:tensorflow-lite-metadata:0.1.0-rc1.
         > Could not get resource 'https://repo.maven.apache.org/maven2/org/tensorflow/tensorflow-lite-metadata/0.1.0-rc1/tensorflow-lite-metadata-0.1.0-rc1.pom'.
            > Could not GET 'https://repo.maven.apache.org/maven2/org/tensorflow/tensorflow-lite-metadata/0.1.0-rc1/tensorflow-lite-metadata-0.1.0-rc1.pom'.
               > The server may not support the client's requested TLS protocol versions: (TLSv1.2, TLSv1.3). You may need to configure the client to allow other protocols to be used. See: https://docs.gradle.org/7.4/userguide/build_environment.html#gradle_system_properties
                  > Remote host terminated the handshake
   > Could not resolve org.ow2.asm:asm-tree:7.0.
     Required by:
         unspecified:unspecified:unspecified > com.android.tools.build:gradle:4.1.0 > com.android.tools.build:builder:4.1.0
      > Could not resolve org.ow2.asm:asm-tree:7.0.
         > Could not get resource 'https://repo.maven.apache.org/maven2/org/ow2/asm/asm-tree/7.0/asm-tree-7.0.pom'.
            > Could not GET 'https://repo.maven.apache.org/maven2/org/ow2/asm/asm-tree/7.0/asm-tree-7.0.pom'.
               > The server may not support the client's requested TLS protocol versions: (TLSv1.2, TLSv1.3). You may need to configure the client to allow other protocols to be used. See: https://docs.gradle.org/7.4/userguide/build_environment.html#gradle_system_properties
                  > Remote host terminated the handshake
   > Could not resolve it.unimi.dsi:fastutil:7.2.0.
     Required by:
         unspecified:unspecified:unspecified > com.android.tools.build:gradle:4.1.0 > com.android.tools.build:builder:4.1.0
      > Could not resolve it.unimi.dsi:fastutil:7.2.0.
         > Could not get resource 'https://repo.maven.apache.org/maven2/it/unimi/dsi/fastutil/7.2.0/fastutil-7.2.0.pom'.            > Could not GET 'https://repo.maven.apache.org/maven2/it/unimi/dsi/fastutil/7.2.0/fastutil-7.2.0.pom'.
               > The server may not support the client's requested TLS protocol versions: (TLSv1.2, TLSv1.3). You may need to configure the client to allow other protocols to be used. See: https://docs.gradle.org/7.4/userguide/build_environment.html#gradle_system_properties
                  > Remote host terminated the handshake
..........

我的 gradle 包裝器屬性:

#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-7.4-all.zip

我的構建 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 flutter.compileSdkVersion
    ndkVersion flutter.ndkVersion

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    kotlinOptions {
        jvmTarget = '1.8'
    }

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

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.example.flut"
        // You can update the following values to match your application needs.
        // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration.
        minSdkVersion flutter.minSdkVersion
        targetSdkVersion flutter.targetSdkVersion
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
    }

    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"
}

我閱讀了一些關於 gradle 不兼容的問題,但我不太了解它,我不明白為什么這些錯誤會准確發生。

更新:我嘗試了一些修復,現在錯誤列表已經減少到這個

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'android'.
> Could not resolve all files for configuration ':classpath'.
   > Could not resolve org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.0.
     Required by:
         project :
      > Could not resolve org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.0.
         > Could not get resource 'https://repo.maven.apache.org/maven2/org/jetbrains/kotlin/kotlin-gradle-plugin/1.7.0/kotlin-gradle-plugin-1.7.0.pom'.
            > Could not GET 'https://repo.maven.apache.org/maven2/org/jetbrains/kotlin/kotlin-gradle-plugin/1.7.0/kotlin-gradle-plugin-1.7.0.pom'.
               > The server may not support the client's requested TLS protocol versions: (TLSv1.2, TLSv1.3). You may need to configure the client to allow other protocols to be used. See: https://docs.gradle.org/7.4/userguide/build_environment.html#gradle_system_properties
                  > Remote host terminated the handshake

* 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\

我認為 TLS 協議版本存在一些問題。 但我找不到太多關於它的細節。

打開 Flutter 終端並運行:

flutter clean
flutter pub get

然后更新你的類路徑:

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

暫無
暫無

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

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