简体   繁体   English

Flutter:任务 ':location:compileDebugKotlin' 执行失败

[英]Flutter: Execution failed for task ':location:compileDebugKotlin'

Execution failed for task ':location:compileDebugKotlin'.

build.gradle(Module:app) build.gradle(模块:应用程序)

    ext.kotlin_version = '1.6.10'
    repositories {
        maven {
            //url 'https://dl.google.com/dl/android/maven2',
            url 'http://download.flutter.io'
        }
        google()
        mavenCentral()
    }

    dependencies {
        classpath 'com.google.gms:google-services:4.3.10'
        classpath 'com.android.tools.build:gradle:4.+'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.google.firebase:firebase-crashlytics-gradle:2.4.1'
        //classpath("com.google.android.libraries.mapsplatform.secrets-gradle-plugin:secrets-gradle-plugin:2.0.0")
    }
}

allprojects {
    repositories {
        maven {
            apply plugin: 'maven'
            //url 'https://dl.google.com/dl/android/maven2',
            url 'http://download.flutter.io'
        }
        google()
        mavenCentral()
    }
}

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

build.gradle(Project) build.gradle(项目)

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 FileNotFoundException ("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

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

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

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
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.develpment.sported_app"
        minSdkVersion 23
        targetSdkVersion 29
        multiDexEnabled true
        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 {
            release {
                profile {
                    matchingFallbacks = ['debug', 'release']
                }
                minifyEnabled true
                useProguard true
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
                signingConfig signingConfigs.release
            }
        //}
    }
    lintOptions {
       disable 'InvalidPackage'
       checkReleaseBuilds false
    }
}

flutter {
    source '../..'
}

dependencies {
    implementation "com.android.support:multidex:1.0.3"
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
    implementation 'com.android.support:support-annotations:28.0.0'
}

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

Solution Tried:解决方案尝试:

  1. Invalidate Caches/Restart使缓存无效/重新启动
  2. Build -> Clean Project构建 -> 清理项目
  3. Updated Kotlin Plugin and used latest Kotlin version更新Kotlin插件,使用最新的Kotlin版本
  4. Run ./gradlew assembleDebug运行./gradlew assembleDebug
  5. Run flutter doctor and flutter clean运行flutter doctorflutter clean

Previously I tried to build for release and the release build, but some features weren't working.以前我尝试过为发布构建和发布构建,但有些功能无法正常工作。 So I looked around and found that I was supposed to add the code below in the main method in the MainActivity.kt in the android section, that's when this issue started.所以我环顾四周,发现我应该在 android 部分的 MainActivity.kt 的主要方法中添加下面的代码,这就是这个问题开始的时候。 I even tried to comment out the method but the error is still there.我什至试图注释掉该方法,但错误仍然存在。

override fun configureFlutterEngine(@NonNull flutterEngine:FlutterEngine){GeneratedPluginRegistrant.registerWith(flutterEngine);}

I updated all my project packages.我更新了我所有的项目包。 That solved the issue for me.这为我解决了这个问题。

This actually worked for me这实际上对我有用

flutter pub upgrade
flutter clean
flutter pub get

I'm also faced same issue, I done with below changes.我也面临同样的问题,我完成了以下更改。 But it's a temporary bug fix.但这是一个临时的错误修复。 For more reference 更多参考

Search for the FlutterLocationService.kt and edit it change the function:搜索 FlutterLocationService.kt 并编辑它更改功能:

onRequestPermissionsResult(requestCode: Int, permissions: Array<out String>?, grantResults: IntArray?): Boolean

to

onRequestPermissionsResult(requestCode: Int, permissions: Array<out String>, grantResults: IntArray): Boolean

You need to equalize kotlin version in first row which is ext.kotlin_version = '1.6.10' to according to classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" of underlined $kotlin_version您需要根据带下划线的 $kotlin_version classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"来均衡第一行中的 kotlin 版本,即ext.kotlin_version = '1.6.10'

After this, problem will solve...之后,问题就解决了……

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Flutter:任务“:app:compileDebugKotlin”执行失败 - Flutter: Execution failed for task ':app:compileDebugKotlin' Flutter 编译错误 - 任务 ':flutter_paystack:compileDebugKotlin' 执行失败 - Flutter compilation error - Execution failed for task ':flutter_paystack:compileDebugKotlin' Flutter: 任务 ':agora_rtc_engine:compileDebugKotlin' 执行失败 - Flutter: Execution failed for task ':agora_rtc_engine:compileDebugKotlin' 任务执行失败&#39;:app:compileDebugKotlin&#39; - Execution failed for task ':app:compileDebugKotlin' flutter hello_world 项目:任务 &#39;:app:compileDebugKotlin&#39; 执行失败 - flutter hello_world project: execution failed for task ':app:compileDebugKotlin' 无法运行 Flutter 应用程序,错误:任务“:应用程序:compileDebugKotlin”执行失败 - Cant Run Flutter App, Error:Execution failed for task ':app:compileDebugKotlin' 任务 ':audioplayers:compileDebugKotlin' 执行失败 - Execution failed for task ':audioplayers:compileDebugKotlin' Flutter 任务执行失败:compileDebugKotlin。 无法转换 flutter.jar 以匹配属性 - Flutter Execution failed for task :compileDebugKotlin. Failed to transform flutter.jar to match attributes 错误:任务“:app:compileDebugKotlin”执行失败 - Error:Execution failed for task ':app:compileDebugKotlin' 任务 ':expo-permissions:compileDebugKotlin' 执行失败 - Execution failed for task ':expo-permissions:compileDebugKotlin'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM