flutter / flutter

Flutter makes it easy and fast to build beautiful apps for mobile and beyond
https://flutter.dev
BSD 3-Clause "New" or "Revised" License
165.01k stars 27.19k forks source link

FontVariationSettings not found when upgrading to Flutter 1.12.13 #46881

Closed alexda12 closed 4 years ago

alexda12 commented 4 years ago

Issue

Since upgrading to 1.12.13 - I can no longer build on Android & get a linking issue android:attr/fontVariationSettings not found. android:attr/ttcIndex not found.

History Have been working on a Flutter app for 15 months and have upgraded regularly and haven't had any major issues. For Android, I have ensured that I am using AndroidX

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 {
        applicationId "my.app.id"
        minSdkVersion 21 
        targetSdkVersion 27
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
    }

    buildTypes {
        release {
            // TODO: Add your own signing config for the release build.
            // Signing with the debug keys for now, so `flutter run --release` works.
            signingConfig signingConfigs.debug
        }
    }
}

flutter {
    source '../..'
}

dependencies {
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
    implementation 'com.google.firebase:firebase-core:16.0.8'  
}

apply plugin: 'com.google.gms.google-services'

Gradle.properties

org.gradle.jvmargs=-Xmx1536M
android.enableJetifier=true
android.useAndroidX=true
android.enableR8=true

Yesterday decided to upgrade to Flutter 1.12.13 hotfix 5 on Stable. Unfortunately I have the following issues on Android

  1. Cannot build APK
  2. Cannot run a release build

Issues on build APK

When running in Terminal Flutter build apk

I get these issues :

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':flutter_twitter_login:verifyReleaseResources'.

    1 exception was raised by workers:
    com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource linking failed /myapp/build/flutter_twitter_login/intermediates/res/merged/release/values/values.xml:247: error: resource android:attr/fontVariationSettings not found. /myapp/build/flutter_twitter_login/intermediates/res/merged/release/values/values.xml:248: error: resource android:attr/ttcIndex not found. error: failed linking references.

Even removing flutter_twitter_login from the app, we get the same error with another plugin 'Shared_preferences' etc.

Plugins

I have a bunch of plugins and have ensured that I obtain the latest versions for at least these plugins :

firebase_auth: 0.15.2 google_sign_in: 4.1.0 cloud_firestore: 0.13.0+1 cloud_functions: 0.4.1+5 shared_preferences: 0.5.6 firebase_storage: 3.0.11

What I can do

iOS

  1. Run my CODE in iOS on Simulator and Live device
  2. Can deploy a RELEASE version of my code on an iOS device

Android

  1. Can run my code in DEBUG mode in Android
  2. Can run my code in DEBUG mode in Android on a Device

Flutter Doctor


Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, v1.12.13+hotfix.5, on Mac OS X 10.15.1 19B88, locale en-GB)
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.0-rc2)
[✓] Xcode - develop for iOS and macOS (Xcode 11.3)
[✓] Android Studio (version 3.5)
[✓] IntelliJ IDEA Community Edition (version 2018.2.3)
[✓] VS Code (version 1.40.2)
[✓] Connected device (3 available)

• No issues found!
iapicca commented 4 years ago

Hi @alexda12 could you please run flutter clean flutter pub cache repair let me know if the issue persists thank you

possibly related to https://github.com/flutter/flutter/issues/46863

alexda12 commented 4 years ago

@iapicca Sorry, I didnt want to mention the obvious, but yes have :

  1. Flutter clean
  2. Flutter pub cache repair
  3. Flutter pub pub cache repair
  4. Deleted build folder
  5. Deleted pubspec.lock, .packages, .flutter-plugins
  6. Ensured compileSdkVersion is 28 in app/build.gradle
  7. Deleted flutter/.pub-cache

I also ensured latest implementation dependencies were referenced as in :


dependencies {
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
    implementation 'com.google.firebase:firebase-core:17.2.1'  
    implementation 'com.google.firebase:firebase-firestore:21.3.1' 
    implementation 'com.google.firebase:firebase-auth:19.2.0' 
    implementation 'com.google.firebase:firebase-functions:19.0.1' 
    implementation 'com.google.firebase:firebase-storage:19.1.0'  
}

but that didnt make any difference so went back to :

dependencies {
     testImplementation 'junit:junit:4.12'
     androidTestImplementation 'androidx.test:runner:1.1.1'
     androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
     implementation 'com.google.firebase:firebase-core:16.0.8' 
 }

apply plugin: 'com.google.gms.google-services'
jlhour commented 4 years ago

Hello, As far as we are concerned, looks like related to keyboard_visibility package: https://github.com/adee42/flutter_keyboard_visibility/issues/42 Thanks

zanderso commented 4 years ago

/cc @blasten

blasten commented 4 years ago

Could you paste the content of the file android/build.gradle and android/app/gradle/wrapper/gradle-wrapper.properties?

blasten commented 4 years ago

I'm able to reproduce @alexda12 issue if I bring the flutter_twitter_login plugin. I fixed the problem if I change https://github.com/roughike/flutter_twitter_login/blob/master/android/build.gradle#L25 (compileSdkVersion: 27 -> compileSdkVersion: 28)

There might be a difference in behavior depending on the version of the Android Gradle plugin that your app is using.

blasten commented 4 years ago

@jlhour Based on my comment above, flutter_keyboard_visibility also has this problem: https://github.com/adee42/flutter_keyboard_visibility/blob/master/android/build.gradle#L25 compileSdkVersion: 27.

alexda12 commented 4 years ago

@blasten - I'm actually using this in my pubspec which is a fork from flutter_twitter_login :

flutter_twitter_login: git: git://github.com/eudangeld/flutter_twitter_login.git

And your right, looking in pub-cache, src -> build.gradle, the minSDK is 27. Changing to 28 resolves the issue. Well spotted and thank you ! So until the plugin owner changes on their side, one has to remember if they clean the pub-cache to manually make the change to this and other plugins that are <=27.

My question is - how come this worked prior to 1.12.13 hotfix 5 - what has changed in Androids build/gradle process with respect to handling pre compileSdkVersion of 28 (i.e 27)?

blasten commented 4 years ago

@alexda12 1.12.13-hotfix.5 involved multiple changes to the Android build system. If you look at the Android documentation for fontVariationSettings, it was added in API level 28. cc @eudangeld who authored this plugin. Would you guys be able to upgrade the plugin and publish a new version?

sarinupreti commented 4 years ago

getting the same error while building a release APK. I tried

flutter build apk --release

and then i tried

flutter clean flutter pub cache repair

but it didn't work

[√] Flutter (Channel unknown, v1.12.13+hotfix.5, on Microsoft Windows [Version 10.0.18363.535], locale en-US) • Flutter version 1.12.13+hotfix.5 at C:\Users\sarin\Documents\flutter • Framework revision 27321ebbad (2 days ago), 2019-12-10 18:15:01 -0800 • Engine revision 2994f7e1e6 • Dart version 2.7.0

[√] Android toolchain - develop for Android devices (Android SDK version 29.0.2) • Android SDK at C:\Program Files\Android\sdk • Android NDK location not configured (optional; useful for native profiling support) • Platform android-29, build-tools 29.0.2 • ANDROID_HOME = C:\Program Files\Android\sdk\tools • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b03) • All Android licenses accepted.

[√] Android Studio (version 3.5) • Android Studio at C:\Program Files\Android\Android Studio • Flutter plugin version 42.0.1 • Dart plugin version 191.8593 • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b03)

[√] VS Code (version 1.40.2) • VS Code at C:\Users\sarin\AppData\Local\Programs\Microsoft VS Code • Flutter extension version 3.7.1

[√] Connected device (1 available) • AOSP on IA Emulator • emulator-5554 • android-x86 • Android 9 (API 28) (emulator)

yasser-alarifi commented 4 years ago

@blasten that fixed the issue for me. Thanks!

PiercarloSlavazza commented 4 years ago

I would like to add that the very same problem (as reported related to flutter_twitter_login) also affects:

which are required e.g. by google_sign_in (v 4.1.0 - which is the latest at the time of writing).

The (temporary) workaround suggested by @alexda12 fixes the problem also in these cases.

eudangeld commented 4 years ago

@alexda12 1.12.13-hotfix.5 involved multiple changes to the Android build system. If you look at the Android documentation for fontVariationSettings, it was added in API level 28. cc @eudangeld who authored this plugin. Would you guys be able to upgrade the plugin and publish a new version?

Updated!

tvolkert commented 4 years ago

/cc @amirh regarding the plugins within flutter/plugins that are affected by this.

blasten commented 4 years ago

@PiercarloSlavazza The compileSdkVersion version was updated to 28 on January 22nd by @mklim in https://github.com/flutter/plugins/commit/59e84d85d948252cfc068917caca2c1ed5b70007. I would suggest you update to the latest version of these plugins.

@mklim do you recall the steps you followed that ended up bumping the SDK version?

PiercarloSlavazza commented 4 years ago

@blasten

The compileSdkVersion version was updated to 28 on January 22nd by @mklim in flutter/plugins@59e84d8. I would suggest you update to the latest version of these plugins.

hm, I proceeded in the following way:

Exactly, @blasten, what do you think I should update? Imho, the broken dependencies are "buried" somewhere in google_sign_in 4.1.0. Or maybe you are suggesting that there is a more recent version of google_sign_in (and threfore its docs are outdated)?

blasten commented 4 years ago

@PiercarloSlavazza could you share the content of pubspec.yaml ?

PiercarloSlavazza commented 4 years ago

@PiercarloSlavazza could you share the content of pubspec.yaml ?

@blasten sure. Just one more thing: I missed to poit out that I am correlating path_provider-0.4.1 and shared_preferences-0.4.3 to google_sign_in because I noticed the relationship by running gradle app:dependencies. That said, here the pubspec.yaml:

name: magicart_fo_app
description: Magicart Flutter App

dependencies:
  background_fetch: "^0.3.2"
  collection: "^1.14.11"
  firebase_messaging: "^6.0.9"
  flutter_facebook_login: "^3.0.0"
  flutter_redux: "^0.5.0"
  flutter_webview_plugin: "^0.3.10"
  google_sign_in: "^4.1.0"
  http: '>=0.11.1 <0.12.0'
  meta: "^1.1.5"
  modal_progress_hud: "^0.1.0"
  numberpicker: "^0.1.7"
  package_info: "^0.4.0+13"
  redux: "^3.0.0"
  redux_persist_flutter:
    git:
      url: git@github.com:nullp01nt3r/redux_persist.git
      path: packages/redux_persist_flutter/
      ref: v0.6.0-save-sync-1
  tuple: "^1.0.2"
  url_launcher: "^5.4.1"
  uuid: "^1.0.0"

  flutter:
    sdk: flutter
  flutter_localizations:
      sdk: flutter

  cupertino_icons: ^0.1.0

dev_dependencies:
  test: "^1.3.0"
  flutter_test:
    sdk: flutter

flutter_icons:
  image_path: "images/logo-magicart-launcher.png"
  android: true

flutter:

  uses-material-design: true

  assets:
    - assets/images/ # ignore: asset_does_not_exist
    - assets/licences/ # ignore: asset_does_not_exist

  fonts:
    - family: OpenSans
      fonts:
        - asset: assets/fonts/OpenSans-Regular.ttf
    - family: OpenSansLight
      fonts:
        - asset: assets/fonts/OpenSans-Light.ttf
    - family: Varela
      fonts:
        - asset: assets/fonts/VarelaRound-Regular.ttf
bluelogoapps commented 4 years ago

After two days of fighting this and in case this helps someone else, what finally resolved this issue for me was a change in my pubspec.yaml file.

I had the following line for the share plugin: share: git: url: https://github.com/d-silveira/flutter-share.git

Once I changed it to: share: ^0.6.3+5

All was well with the world.I was able to build successfully.

honkevin commented 4 years ago

Same problem here.

$ flutter build apk --split-per-abi registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection) registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection) registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)

FAILURE: Build failed with an exception.

BUILD FAILED in 3s

adrianvintu commented 4 years ago

see this https://github.com/adee42/flutter_keyboard_visibility/issues/42#issuecomment-566656630

luckymehndiratta commented 4 years ago

same issue FAILURE: Build failed with an exception.

Anyoks commented 4 years ago

Same issue here flutter version v1.12.13+hotfix.6

wangyanjun commented 4 years ago

Same issue here flutter version 1.13.5 dev channel .
command: flutter build apk --release response: '* What went wrong: Execution failed for task ':shared_preferences:verifyReleaseResources'.

1 exception was raised by workers: com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource linking failed \build\shared_preferences\intermediates\res\merged\release\values\values.xml:236: error: resource android:attr/fontVariationSettings not found. \build\shared_preferences\intermediates\res\merged\release\values\values.xml:237: error: resource android:attr/ttcIndex not found. error: failed linking references.'

no-response[bot] commented 4 years ago

Without additional information, we are unfortunately not sure how to resolve this issue. We are therefore reluctantly going to close this bug for now. Please don't hesitate to comment on the bug if you have any more information for us; we will reopen it right away! Thanks for your contribution.

zanderso commented 4 years ago

Re-opening since this issue still looks active.

StephanCassel commented 4 years ago

Panic! Has anyone solved this?

error: resource android:attr/fontVariationSettings not found. error: resource android:attr/ttcIndex not found.

✓] Flutter (Channel stable, v1.12.13+hotfix.5, on Mac OS X 10.14.6 18G103, locale en-NO) • Flutter version 1.12.13+hotfix.5 at /Users/stephan/development/flutter • Framework revision 27321ebbad (9 weeks ago), 2019-12-10 18:15:01 -0800 • Engine revision 2994f7e1e6 • Dart version 2.7.0

[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3) • Android SDK at /Users/stephan/Library/Android/sdk • Android NDK location not configured (optional; useful for native profiling support) • Platform android-29, build-tools 28.0.3 • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405) • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 11.3) • Xcode at /Applications/Xcode.app/Contents/Developer • Xcode 11.3, Build version 11C29 • CocoaPods version 1.7.5

[✓] Android Studio (version 3.5) • Android Studio at /Applications/Android Studio.app/Contents • Flutter plugin version 43.0.1 • Dart plugin version 191.8593 • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)

[!] IntelliJ IDEA Community Edition (version 2017.1.1) • IntelliJ at /Applications/IntelliJ IDEA CE.app ✗ Flutter plugin not installed; this adds Flutter specific functionality. ✗ Dart plugin not installed; this adds Dart specific functionality. • For information about installing plugins, see https://flutter.dev/intellij-setup/#installing-the-plugins

[!] VS Code (version 1.35.1) • VS Code at /Applications/Visual Studio Code.app/Contents ✗ Flutter extension not installed; install from https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[✓] Connected device (1 available) • LYA L29 • LHS7N18A13001240 • android-arm64 • Android 10 (API 29)

StephanCassel commented 4 years ago

Yiiihaaaa !!! devicelocale: ^0.2.0 to devicelocale: ^0.2.1 did the trick

agersea commented 4 years ago

I'm running into this problem as well. I followed all the suggestions and am still unable to generate APK files.

ChinKX commented 4 years ago

For those whose flutter option is greyed out in the Android Studio may try this solution out: https://github.com/flutter/flutter-intellij/issues/3873#issuecomment-498467233

iapicca commented 4 years ago

Hi @alexda12 are you still experiencing the issue with the latest stable? Thank you

sandeepng9 commented 4 years ago

I'm running into this problem as well. I followed all the suggestions and am still unable to generate APK files.

FAILURE: Build failed with an exception.

build.gradle:-

android { compileSdkVersion 28

lintOptions {
    disable 'InvalidPackage'
}

defaultConfig {
    minSdkVersion 19
    targetSdkVersion 28
    versionCode flutterVersionCode.toInteger()
    versionName flutterVersionName
    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

Pubspec.yaml file:-

The following defines the version and build number for your application.

A version number is three numbers separated by dots, like 1.2.43

followed by an optional build number separated by a +.

Both the version and the builder number may be overridden in flutter

build by specifying --build-name and --build-number, respectively.

In Android, build-name is used as versionName while build-number used as versionCode.

Read more about Android versioning at https://developer.android.com/studio/publish/versioning

In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.

Read more about iOS versioning at

https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html

version: 9.2.5+9.2.5

environment: sdk: ">=2.2.0 <3.0.0"

dependencies: flutter: sdk: flutter

The following adds the Cupertino Icons font to your application.

Use with the CupertinoIcons class for iOS style icons.

cupertino_icons: ^0.1.2 flutter_typeahead: ^1.3.0 http: ^0.12.0+1 json_annotation: ^2.0.0 image_picker: ^0.6.2+3 image_cropper: ^1.1.1 intl: ^0.15.8 device_info: ^0.4.0+1 sqflite: ^1.1.5 path_provider: ^0.5.0+1 connectivity: ^0.3.0 image: ^2.0.7 flutter_pagewise: ^1.2.3 cached_network_image: 2.0.0-rc

collection: ^1.14.11 firebase_messaging: ^6.0.9 rflutter_alert: ^1.0.2 firebase_dynamic_links: ^0.4.0+2 encrypt: ^2.0.0 flutter_circular_chart: ^0.1.0 vibration: 1.1.0 transparent_image: ^0.1.0 flutter_swiper: ^1.1.6 flutter_custom_clippers: ^1.1.0 url_launcher: ^5.4.1 fluttertoast: ^3.1.3
barcode_scan: ^1.0.0 flutter_local_notifications: ^0.9.0+1 charts_flutter: ^0.5.0 flutter_youtube: "^2.0.0" flutter_speed_dial: ^1.2.5 flutter_automation: ^1.1.2

dev_dependencies: flutter_test: sdk: flutter

For information on the generic Dart part of this file, see the

following page: https://www.dartlang.org/tools/pub/pubspec

The following section is specific to Flutter.

flutter:

The following line ensures that the Material Icons font is

included with your application, so that you can use the icons in

the material Icons class.

uses-material-design: true

To add assets to your application, add an assets section, like this:

assets:

- images/a_dot_burr.jpeg

- images/a_dot_ham.jpeg

assets:

no-response[bot] commented 4 years ago

Without additional information, we are unfortunately not sure how to resolve this issue. We are therefore reluctantly going to close this bug for now. Please don't hesitate to comment on the bug if you have any more information for us; we will reopen it right away! Thanks for your contribution.

PaccoreIT commented 4 years ago

any update on it?

IamArmaan commented 3 years ago

Yes , this solution is working after spending few hours https://stackoverflow.com/a/58576562/9545222

github-actions[bot] commented 3 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.