任务“:app:lintVitalRelease”的执行失败。扑

MHD*_*DEZ 29 gradle flutter

为什么我会收到这些错误 我尝试发布 apk

我运行“flutter build apk --release”

任务“:app:lintVitalRelease”的执行失败。 :app:lintVitalRelease 配置根项目“android_intent”时出现问题。

  • 出了什么问题:配置根项目“android_intent”时出现问题。

未找到 SDK 位置。使用 local.properties 文件中的 sdk.dir 或 ANDROID_HOME 环境变量定义位置。

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"

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.deleviry"

   minSdkVersion 21
        targetSdkVersion 28
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        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 'com.google.firebase:firebase-core:17.2.0'
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" }

apply plugin: 'com.google.gms.google-services'
Run Code Online (Sandbox Code Playgroud)

android/build.gradle

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

    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.0'
        classpath 'com.google.gms:google-services:4.3.3'
        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 }
Run Code Online (Sandbox Code Playgroud)

jos*_*cha 62

升级 gradle 构建工具似乎会破坏一些 lint。

要解决此问题,您可以:

如果你的错误是 debug/libs.jar,构建 --debug 然后 --release。
如果你的错误是 profile/libs.jar,构建 --profile 然后 --release。

来自https://github.com/flutter/flutter/issues/58247#issuecomment-636500680

如果上述方法不起作用,您可以禁用检查。

添加checkReleaseBuilds falselintOptionsAndroid设备/应用/的build.gradle文件。

android {
    ...
    lintOptions {
        disable 'InvalidPackage'
        checkReleaseBuilds false //<- add this line
    }
}
Run Code Online (Sandbox Code Playgroud)

  • 这会禁用检查!所以它没有被执行,并且根本问题没有得到解决! (12认同)

And*_*eev 7

如果您的错误提示debug/libs.jar,请--debug构建--release

flutter build apk --debug
flutter build apk --release
Run Code Online (Sandbox Code Playgroud)

如果您的错误提示profile/libs.jar,请--profile构建--release

flutter build apk --profile
flutter build apk --release
Run Code Online (Sandbox Code Playgroud)

取自这里