Johann Feser
Johann Feser

Reputation: 445

Flutter Gradle build exception

Because there is a bug with Flutter and android pie or sdk 28 there by the keyboard won't appear when touching a textfield I wanted to try to downgrade the compile and target sdk back to 27. I upgraded them a week or so ago and back then everything worked on version 27. But when I try to build it now I get this error.

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 doctor

[√] 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
}

Upvotes: 4

Views: 5309

Answers (3)

user7418129
user7418129

Reputation: 1114

I created another flutter app and replaced all the .dart files and also the packages in pubspec.yaml. It is the fastest method I found. Other methods may cause new errors or sometimes worthless.

Upvotes: 0

marp
marp

Reputation: 474

I managed to solve it by removing one by one the dart packages on the pubspec.yaml file and see which one was causing the error. For me particularly, I was using image_picker which introduced a breaking change on the version 0.5.0, so I just downgraded to the previous version and it worked.

Upvotes: 0

rmtmckenzie
rmtmckenzie

Reputation: 40513

I think the problem is that you're trying to use the 28.0 version of AppCompat, with a build version of 27 (maybe one of your dependencies is requiring it?).

Try explicitly requiring the 27.* version (add compile 'com.android.support:appcompat-v7:27.1.1' to your dependencies. If you get a version conflict then you may have to downgrade some of your flutter plugin dependencies as well.

Upvotes: 2

Related Questions