gradle 在Flutter中配置项目“:wakelock”时出现问题

cidc1ykv  于 4个月前  发布在  Flutter
关注(0)|答案(1)|浏览(135)

所以我一直在尝试运行我的Flutter应用程序,但我不断得到错误的错误。当我运行Flutter运行,这是我得到的

Launching lib\main.dart on M2102J20SG in debug mode...

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':wakelock'.
> Could not resolve all artifacts for configuration ':wakelock:classpath'.
   > Could not resolve org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.31.
     Required by:
         project :wakelock
      > Could not resolve org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.31.
         > Could not get resource 'https://repo.maven.apache.org/maven2/org/jetbrains/kotlin/kotlin-gradle-plugin/1.5.31/kotlin-gradle-plugin-1.5.31.pom'.
            > Could not GET 'https://repo.maven.apache.org/maven2/org/jetbrains/kotlin/kotlin-gradle-plugin/1.5.31/kotlin-gradle-plugin-1.5.31.pom'.
               > Connect to repo.maven.apache.org:443 [repo.maven.apache.org/151.101.60.215] failed: Connection timed out: connect
> Failed to notify project evaluation listener.
   > Could not get unknown property 'android' for project ':wakelock' of type org.gradle.api.Project.
   > Could not get unknown property 'android' for project ':wakelock' of type org.gradle.api.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 21m 48s
Running Gradle task 'assembleDebug'...                           1323.8s
[!] Gradle threw an error while downloading artifacts from the network. Retrying to download...

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':wakelock'.
> Could not resolve all artifacts for configuration ':wakelock:classpath'.
   > Could not download kotlin-compiler-embeddable-1.5.31.jar (org.jetbrains.kotlin:kotlin-compiler-embeddable:1.5.31)
      > Could not get resource 'https://repo.maven.apache.org/maven2/org/jetbrains/kotlin/kotlin-compiler-embeddable/1.5.31/kotlin-compiler-embeddable-1.5.31.jar'.
         > Could not GET 'https://repo.maven.apache.org/maven2/org/jetbrains/kotlin/kotlin-compiler-embeddable/1.5.31/kotlin-compiler-embeddable-1.5.31.jar'.
            > Remote host terminated the handshake
   > Could not download kotlin-scripting-jvm-1.5.31.jar (org.jetbrains.kotlin:kotlin-scripting-jvm:1.5.31)
      > Could not get resource 'https://repo.maven.apache.org/maven2/org/jetbrains/kotlin/kotlin-scripting-jvm/1.5.31/kotlin-scripting-jvm-1.5.31.jar'.
         > Could not GET 'https://repo.maven.apache.org/maven2/org/jetbrains/kotlin/kotlin-scripting-jvm/1.5.31/kotlin-scripting-jvm-1.5.31.jar'.
            > Remote host terminated the handshake
> Failed to notify project evaluation listener.
   > Could not get unknown property 'android' for project ':wakelock' of type org.gradle.api.Project.
   > Could not get unknown property 'android' for project ':wakelock' of type org.gradle.api.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 2m 34s
Running Gradle task 'assembleDebug'...                            164.8s
[!] Gradle threw an error while downloading artifacts from the network. Retrying to download...
Exception: Gradle task assembleDebug failed with exit code 1

字符串
这是我的build.gradle文件

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

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

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
}


这是我的android/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"


def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
    keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}

android {
    compileSdkVersion 31

    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.murya.marveldcnews"
        minSdkVersion 21
        targetSdkVersion 31
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
    }

    signingConfigs {
       release {
           keyAlias keystoreProperties['keyAlias']
           keyPassword keystoreProperties['keyPassword']
           storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
           storePassword keystoreProperties['storePassword']
       }
   }
   buildTypes {
       release {
           signingConfig signingConfigs.release
       }
   }
}

flutter {
    source '../..'
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}

apply plugin: 'com.google.gms.google-services'


我试过删除gradle缓存,升级flutter,我已经将密钥库文件位置上的反斜杠更改为正斜杠
我的flutter doctor

Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 2.10.5, on Microsoft Windows [Version 10.0.19043.1645], locale en-NG)
[√] Android toolchain - develop for Android devices (Android SDK version 32.0.0)
[√] Chrome - develop for the web
[X] Visual Studio - develop for Windows
    X Visual Studio not installed; this is necessary for Windows development.
      Download at https://visualstudio.microsoft.com/downloads/.
      Please install the "Desktop development with C++" workload, including all of its default components
[√] Android Studio (version 2020.3)
[√] VS Code (version 1.66.2)
[√] Connected device (4 available)
[√] HTTP Host Availability

! Doctor found issues in 1 category.


我不是为Windows开发的,所以我想这是不必要的...

woobm2wo

woobm2wo1#

您是否使用flutter_html。如果您使用,flutter_html 2.1.2依赖于wakelock 0.4.0,而wakelock 0.4.0不支持Kotlin 1.5

相关问题