14

I'm working on Flutter app. I can run app in the android device successfully but try to make build (.apk) file and got below issues.

FAILURE: Build failed with an exception.                                                                           

* What went wrong:                                                                                                 
Execution failed for task ':flutter_twitter:verifyReleaseResources'.                                               
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade                  
   > Android resource linking failed                                                                               
     /Users/ipatel/.gradle/caches/transforms-2/files-2.1/8f09fa5c6115de167b21b323f769edd9/core-1.0.0/res/values/values.xml:57:5-88:25: AAPT: error: resource android:attr/fontVariationSettings not found.

     /Users/ipatel/.gradle/caches/transforms-2/files-2.1/8f09fa5c6115de167b21b323f769edd9/core-1.0.0/res/values/values.xml:57:5-88:25: AAPT: error: resource android:attr/ttcIndex not found.


* 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 5m 2s                                                                                              
Running Gradle task 'assembleRelease'...                                                                           
Running Gradle task 'assembleRelease'... Done                     303.8s (!)
The built failed likely due to AndroidX incompatibilities in a plugin. The tool is about to try using Jetfier to solve the incompatibility.
Building plugin firebase_messaging...
The plugin firebase_messaging could not be built due to the issue above.

Below are project's stuffs

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

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
}

> local.properties

sdk.dir=/Users/ipatel/Library/Android/sdk
flutter.sdk=/Users/ipatel/Documents/Amit/FlutterSetup/flutter
flutter.buildMode=release
flutter.versionName=1.0.0
flutter.ver

My app is compatible with AndroidX and also tried with many solution but can't able to fix my issue.

I checked
- https://github.com/roughike/flutter_twitter_login/issues/29
- A failure occurred while executing com.android.build.gradle.internal.tasks
- flutter Error "Android dependency 'androidx.core:core' has different version" using flutter_local_notifications and location packages

and others.

Flutter Doctor Result:

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel beta, v1.12.13+hotfix.6, on Mac OS X 10.14.3 18D109, locale en-IN)

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
[✓] Xcode - develop for iOS and macOS (Xcode 10.3)
[✓] Chrome - develop for the web
[✓] Android Studio (version 3.5)
[✓] VS Code (version 1.41.1)
[✓] Connected device (4 available)

build.gradle

android {
    compileSdkVersion 28

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }

    lintOptions {
        disable 'InvalidPackage'
    }

    defaultConfig {
        applicationId "com.xxxx.aaaa"
        minSdkVersion 21
        targetSdkVersion 28
        multiDexEnabled true
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    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
        }
    }
}

gradle.properties

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

~PS : Let me know if you want more details from my end.

iPatel
  • 46,010
  • 16
  • 115
  • 137
  • What is the version of your flutter – Blasanka Dec 30 '19 at 08:28
  • @Blasanka Flutter (Channel beta, v1.12.13+hotfix.6) – iPatel Dec 30 '19 at 10:00
  • Did you try adding multiDex to true, if so if you can try with master or stable channel. – Blasanka Dec 30 '19 at 11:58
  • @Blasanka I have already set that pls check my **build.gradle** file – iPatel Dec 31 '19 at 04:35
  • can you post contents of your `gradle.properties` file? – Harshvardhan Joshi Dec 31 '19 at 04:38
  • @HarshvardhanJoshi pls check updated – iPatel Dec 31 '19 at 04:48
  • these are not full build.gradle files? are they? It would be great if you add complete files with sensitive/private information removed... If they are full, they are not configured for firebase API use. – Harshvardhan Joshi Dec 31 '19 at 05:10
  • Just For reference: https://firebase.google.com/docs/flutter/setup?platform=android – Harshvardhan Joshi Dec 31 '19 at 05:11
  • also, make sure that the android project's gradle plugin is updated. you can check it in `android\gradle\wrapper\gradle-wrapper.properties`. Any version above 3.5.3 is fine. – Harshvardhan Joshi Dec 31 '19 at 05:14
  • @HarshvardhanJoshi actually issue is because of `flutter_twitter` plugin if I remove from my project then able to make .apk file, If possible then just create new project just add `flutter_twitter` plugin and try to make android build by `flutter build apk` – iPatel Dec 31 '19 at 05:24
  • I tried creating the project you said and it failed as you said. it seems that you have already found the [issue on github](https://github.com/roughike/flutter_twitter_login/issues/30). I think there's nothing more to it for now. – Harshvardhan Joshi Dec 31 '19 at 06:20

8 Answers8

14

The issue is some library is not compatible or not using androidx while others are. Thanks to google for transferring all support lib to androidx now many libraries having conflicts like this and I mostly go to debug around which lib has an issue like commenting and uncommenting the lib from pubspec.

Assuming the flutter_twitter plugin was the issue.

As we can check that, that twitter plugin not using AndroidX link so we need to change it our self.

(all these changes needs to be changed in twitter plugin, not flutter project)

I think you can change the gradle.properties to use androidx and also compile version to 28 gradle.properties:

android.useAndroidX=true
android.enableJetifier=true

add this two lines, change gradle classpath classpath 'com.android.tools.build:gradle:3.5.3' and compileSdkVersion 28 in flutter_twitter. I am able to generate release build using that plugin.

Ohh yah you can find your cached version of plugin at /Users/parth.dave/.pub-cache/hosted/pub.dartlang.org/flutter_twitter_login-1.1.0/ something like this where you can update it. or either open android folder in androidstudio and studio will show you two projects app and twitter where you can update this things.

also sometimes it's better to open android project in android studio and update all things from which you might get errors before running flutter projects.

Community
  • 1
  • 1
Parth Dave
  • 2,096
  • 13
  • 20
  • hope this might solve your issue. do comment if not, I will try to find another solution. – Parth Dave Jan 02 '20 at 09:59
  • Thanks for answer pratik, Actually I just created new project in Fluter where "android.useAndroidX=true, android.enableJetifier=true" and `compileSdkVersion 28` already set in the project and I just changed `'com.android.tools.build:gradle:3.5.3'` and try to make build by `flutter build apk` and got same issue – iPatel Jan 02 '20 at 14:00
  • No no I was talking about changing the twitter plugin settings not your project settings. – Parth Dave Jan 03 '20 at 06:35
  • Yes.. I got solution, Thank you – iPatel Jan 06 '20 at 15:13
5

Problem is with Execution failed for task ':flutter_twitter:verifyReleaseResources'. i found link for this issue flutter_twitter_login/issue #12

Add this dependency in your pubspec.yaml file and let me know this working or not?

flutter_twitter_login: 
  git: git://github.com/eudangeld/flutter_twitter_login.git
Aamil Silawat
  • 7,735
  • 3
  • 19
  • 37
3

Goto the android studio external libraries in the left side

--> select the library that cause this issue

--> then goto the android -> build.gradle and update the compileSdkVersion to 28 enter image description here

enter image description here

Muhammad Tameem Rafay
  • 3,602
  • 2
  • 21
  • 32
2

You need to update the compileSdkVersion of the flutter_twitter module to 28 :

1/ In your flutter project, locate your "android" folder and open it as an android project in Android Studio.

2/ Expand "Gradle Scripts" and wait for it to load.

3/ Locate "build.gradle (Module: flutter_twitter)"

4/ Modify the compileSdkVersion from 27->28.

5/ Save the changes.

My build worked after that. The answer was here : https://github.com/flutter/flutter/issues/32595

Florian Lavorel
  • 744
  • 2
  • 8
  • 14
1

thank you, it worked for me for device_id: ^0.1.3

plugin conflit with cloud_firestore: ^0.13.4+2

  1. In your flutter project, locate your android folder and open it as an android project in Android Studio.

  2. Expand Gradle Scripts and wait for it to load.

  3. Locate build.gradle (Module: device_id)

  4. Modify the compileSdkVersion from 27 -> 28.

  5. Save the changes.

helvete
  • 2,455
  • 13
  • 33
  • 37
Om28dz Alg
  • 11
  • 1
1

I faced a similar issue and here is how I fixed it by following this link.

  1. In Android Studio (with your project open) right-click the android folder, and click "Flutter"->"Open Android Module in Android Studio". Select "Open in New Window"
  2. In the new window, Wait for Gradle to finish the sync
  3. Expand "Gradle Scripts"
  4. Locate "build.gradle (Module: flutter_twitter)" or which so ever package is throwing the error
  5. Modify the compileSdkVersion from 28->29 (or whatever is defined in your android/app/build.gradle file).
  6. Save the changes and run flutter clean
  7. Build the signed apk.
Hadi Mir
  • 4,497
  • 2
  • 29
  • 31
0

seems like your firebase_messaging library version does not support AndroidX support. Make sure you have updated version of this library.

dependencies:
  firebase_messaging: ^6.0.9
KumarSunil17
  • 224
  • 2
  • 6
0

I had the same problem before and it took almost a half day to find a solution. My project compileSdkVersion was already 28 but in my case app-usage package compileSdkVersion was under 28 and i had to change it manually in /home/"user"/.pub-cache/hosted/pub.dartlang.org/"package with problem"/android/build.gradle. and it solved the problem.