Flutter Gradle构建异常

时间:2018-10-26 16:29:59

标签: android gradle flutter

因为Flutter和android pie或sdk 28出现错误,所以在触摸文本字段时键盘不会显示该错误,因此我想将编译级别降为27,并将sdk定位为27。之前和之后,一切都适用于版本27。但是,当我现在尝试构建它时,出现此错误。

Launching lib\main.dart on ONEPLUS A6003 in debug mode...
Initializing gradle...
Resolving dependencies...
Gradle task 'assembleDebug'...
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
C:\Users\user\.gradle\caches\transforms-1\files-1.1\appcompat-v7-28.0.0.aar\06dacde0fc29b2587bc44934e40ef762\res\values-v28\values-v28.xml:9:5-12:13: AAPT: error: resource android:attr/dialogCornerRadius not found.

C:\Users\user\Project\yapp_mobile\build\app\intermediates\incremental\mergeDebugResources\merged.dir\values-v28\values-v28.xml:11: AAPT: error: resource android:attr/dialogCornerRadius not found.

C:\Users\user\.gradle\caches\transforms-1\files-1.1\appcompat-v7-28.0.0.aar\06dacde0fc29b2587bc44934e40ef762\res\values\values.xml:1304:5-69: AAPT: error: resource android:attr/fontVariationSettings not found.

C:\Users\user\.gradle\caches\transforms-1\files-1.1\appcompat-v7-28.0.0.aar\06dacde0fc29b2587bc44934e40ef762\res\values\values.xml:1304:5-69: AAPT: error: resource android:attr/ttcIndex not found.


FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processDebugResources'.
> Failed to process resources, see aapt output above for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 17s
Finished with error: Gradle task assembleDebug failed with exit code 1

颤抖的医生

[√] Flutter (Channel master, v0.10.2-pre.69, on Microsoft Windows [Version 10.0.17134.345], locale de-DE)
[√] Android toolchain - develop for Android devices (Android SDK 27.0.3)
[√] Android Studio (version 3.2)
[√] IntelliJ IDEA Ultimate Edition (version 2017.3)
[!] VS Code, 64-bit edition (version 1.25.1)
[√] Connected device (1 available)

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.")
}

apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
def keystorePropertiesFile = rootProject.file("key.properties")
def keystoreProperties = new Properties()
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
android {
    compileSdkVersion 27

    lintOptions {
        disable 'InvalidPackage'
    }

    defaultConfig {
        applicationId "com.my.app"
        minSdkVersion 19
        targetSdkVersion 27
        versionCode 6
        versionName "1"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
    }
    signingConfigs {
        release {
            keyAlias keystoreProperties['keyAlias']
            keyPassword keystoreProperties['keyPassword']
            storeFile file(keystoreProperties['storeFile'])
            storePassword keystoreProperties['storePassword']
        }
    }
    buildTypes {
        release {
            signingConfig signingConfigs.release

            minifyEnabled true
            useProguard true

            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

flutter {
    source '../..'
}

dependencies {
    implementation 'com.google.firebase:firebase-messaging:17.3.4'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation 'com.android.support:multidex:1.0.3'
}
apply plugin: 'com.google.gms.google-services'

android / build.gradle

buildscript {
    repositories {
        google()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.3'
        classpath 'com.google.gms:google-services:3.2.1'
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        maven { url "https://jitpack.io" }
    }
}

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

task clean(type: Delete) {
    delete rootProject.buildDir
}

3 个答案:

答案 0 :(得分:2)

我认为问题在于您正在尝试使用AppCompat的28.0版本,其构建版本为27(也许您的依赖项之一需要它?)。

尝试明确要求使用27. *版本(将compile 'com.android.support:appcompat-v7:27.1.1'添加到您的依赖项中。如果遇到版本冲突,则可能还必须降级某些flutter插件的依赖项。

答案 1 :(得分:0)

我设法通过逐个删除pubspec.yaml文件上的dart程序包来解决它,并查看是哪个引起了错误。特别是对我来说,我使用的是image_picker,它对版本0.5.0进行了重大更改,因此我只是降级到以前的版本,并且可以正常工作。

答案 2 :(得分:0)

我创建了另一个flutter应用程序,并替换了所有.dart文件以及pubspec.yaml中的软件包。这是我找到的最快的方法。其他方法可能会导致新的错误,有时甚至一文不值。