【问题标题】:Could not determine the dependencies of task ':app:lintVitalRelease' flutter build error无法确定任务':app:lintVitalRelease'颤振构建错误的依赖关系
【发布时间】:2022-01-01 02:33:25
【问题描述】:

构建apk后的输出:

    FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':app:lintVitalRelease'.
> Could not resolve all artifacts for configuration ':app:debugAndroidTestCompileClasspath'.
   > Could not find com.google.firebase:firebase-analytics:.
     Required by:
         project :app

这是我在 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 30

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

    lintOptions {
        disable 'InvalidPackage'
    }

    defaultConfig {
        applicationId "com.XXXX.XXXXX"
        minSdkVersion 21
        targetSdkVersion 31
        versionCode 7
        versionName "1.2.8"
        multiDexEnabled true
    }

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


}

flutter {
    source '../..'
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'com.google.firebase:firebase-analytics'
}
apply plugin: 'com.google.gms.google-services'

这是我在 android 目录中的 build.gradle:

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

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

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
}

我该如何解决这个问题,我尝试升级 gradle 版本但没有任何效果,并且更新了我所有的包仍然相同。任何帮助表示赞赏 - 我的颤振版本是 2.8.1。

【问题讨论】:

  • 发布你的构建文件
  • @JustInCoding,我按要求添加了 build.gradle 文件。
  • 希望这个解决方案能帮到你 stackoverflow.com/a/64824927/17797499>
  • 添加 firebase-analytics 插件的版本。
  • 现在它显示此错误:您的项目需要更新版本的 Kotlin Gradle 插件。在kotlinlang.org/docs/gradle.html#plugin-and-versions上找到最新版本,然后更新D:\xxxxxx\xxxx\android\build.gradle: ext.kotlin_version = '

标签: flutter gradle build


【解决方案1】:

我在我的项目中实现了 Firebase,并在尝试发布时遇到了同样的错误,我进入 android/app/build.gradle 并添加了这个,它运行良好:

kotlinOptions {
    jvmTarget = '1.8'
}

lintOptions {
    disable 'InvalidPackage'
    checkReleaseBuilds false
}

【讨论】:

    猜你喜欢
    • 2020-04-15
    • 2021-06-18
    • 2021-09-10
    • 2021-04-01
    • 1970-01-01
    • 2019-12-23
    • 2020-10-28
    • 2021-01-26
    • 1970-01-01
    相关资源
    最近更新 更多