繁体   English   中英

Gradle 失败可能是因为这个 Flutter 应用程序中的 AndroidX 不兼容

[英]The Gradle failure may have been because of AndroidX incompatibilities in this Flutter app

将依赖项类路径从'com.android.tools.build:gradle:3.2.1'更新为*'com.android.tools.build:gradle:3.3.2'时会出现此问题

项目级build.gradle

buildscript {
        repositories {
            google()
            jcenter()
        }

        dependencies {
            classpath 'com.android.tools.build:gradle:3.3.2'
        }
    }

    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
    }

应用级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 from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

    android {
        compileSdkVersion 28

        lintOptions {
            disable 'InvalidPackage'
        }

        defaultConfig {
            // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
            applicationId "org.company.com.flutter_app"
            minSdkVersion 19
            targetSdkVersion 28
            versionCode flutterVersionCode.toInteger()
            versionName flutterVersionName
            testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        }

        buildTypes {
            release {
                signingConfig signingConfigs.debug
            }
        }
    }

    flutter {
        source '../..'
    }

    dependencies {
        testImplementation 'junit:junit:4.12'
    }

发布规范.yaml

dependencies:
flutter:
  sdk: flutter
cupertino_icons: ^0.1.2

dev_dependencies:
flutter_test:
  sdk: flutter
flutter_svg: ^0.12.0
printing: ^2.0.0
image: ^2.0.7

在android / gradle.properties中添加:

android.useAndroidX=true
android.enableJetifier=true

参考: https//flutter.dev/docs/development/packages-and-plugins/androidx-compatibility

检查这两个链接后我遇到了同样的问题: https//flutter.dev/docs/deployment/android

proguard 唯一对我minifyEnabled true是删除minifyEnabled true fom build.graddle。

希望它有所帮助。

您似乎正在使用与Androidx不兼容的Flutter依赖项,尝试评论最近的依赖项并重新运行它,如果它有效,请尝试使用与Androidx兼容的依赖项

确保所有资产都在使用中。

然后flutter pub get然后flutter pub upgrade然后flutter pup outdated

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM