无法生成android apk扑

我必须生成我的flutter应用程序的android apk,要执行此操作,请先运行flutter clean,然后再进行flutter构建apk,执行apk构建时,我在下面报告了以下错误,你们中有人知道如何解决这些错误吗?

build.gradle:

buildscript {
    ext.kotlin_version = '1.3.50'
    repositories {
        google()
        jcenter()
         maven { url 'https://maven.fabric.io/public' }
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.4'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        //classpath 'com.android.tools.build:gradle:3.3.0'
        classpath 'com.google.gms:google-services:4.2.0'
        classpath 'io.fabric.tools:gradle:1.30.0'
    }

    //compileSdkVersion 28
}

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
}

错误:

     1) Android dependency 'androidx.core:core' has different version for the compile (1.1.0)
        and runtime (1.2.0) classpath. You should manually set the same version via DependencyResolution

    2). Execution failed for task ':app:preReleaseBuild'.                       
    > Android dependency 'com.android.support:support-v4' has different version for the compile (27.1.1) 
and runtime (28.0.0) classpath. You should manually set the same version via DependencyResolution
评论
  • wiusto
    wiusto 回复

    尝试将其粘贴到构建脚本下的build.gradle中:

    subprojects {
        project.configurations.all {
            resolutionStrategy.eachDependency { details ->
                if (details.requested.group == 'com.android.support'
                        && !details.requested.name.contains('multidex') ) {
                    details.useVersion "27.1.1"
                }
                if (details.requested.group == 'androidx.core'
                        && !details.requested.name.contains('androidx') ) {
                    details.useVersion "1.0.1"
                }
            }
        }
    }
    

    For more details see: https://github.com/flutter/flutter/issues/27254