I wanted to add firebase_messaging package to my flutter module and failing to build aar. I am using flutter 3.0.1. Steps to reproduce:
flutter create -t module --org com.example my_flutter_abc
cd my_flutter_abc
flutter pub add firebase_messaging
flutter build aar
Getting the following error
Running "flutter pub get" in my_flutter_abc... 2,428ms
Building with sound null safety
Running Gradle task 'assembleAarDebug'... 33.6s
Warning: The plugin firebase_messaging requires Android SDK version 33.
For more information about build configuration, see https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration.
One or more plugins require a higher Android SDK version.
Fix this issue by adding the following to C:\workspace\flutter-module\my_flutter_abc\.android\Flutter\build.gradle:
android {
compileSdkVersion 33
...
}
c:\flutter_3_0_1\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_messaging-14.1.4\android\src\main\java\io\flutter\plugins\firebase\messaging\FlutterFirebaseMessagingPlugin.java:399: error: cannot find symbol
.checkSelfPermission(Manifest.permission.POST_NOTIFICATIONS)
^
symbol: variable POST_NOTIFICATIONS
location: class permission
c:\flutter_3_0_1\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_messaging-14.1.4\android\src\main\java\io\flutter\plugins\firebase\messaging\FlutterFirebasePermissionManager.java:63: error: cannot find symbol
permissions.add(Manifest.permission.POST_NOTIFICATIONS);
^
symbol: variable POST_NOTIFICATIONS
location: class permission
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: c:\flutter_3_0_1\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_messaging-14.1.4\android\src\main\java\io\flutter\plugins\firebase\messaging\FlutterFirebaseMessagingPlugin.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
2 errors
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':firebase_messaging:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output 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 32s
Gradle task assembleAarDebug failed with exit code 1.
Modified my_flutter_abc.android\Flutter\build.gradle to use
android {
compileSdkVersion 33
....
}
then getting the following error when run flutter build aar again
Building with sound null safety
Running Gradle task 'assembleAarDebug'... 15.8s
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: c:\flutter_3_0_1\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_messaging-14.1.4\android\src\main\java\io\flutter\plugins\firebase\messaging\FlutterFirebaseMessagingPlugin.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':firebase_messaging:uploadArchives'.
> Could not publish configuration 'archives'
> Could not write to file 'c:\flutter_3_0_1\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_messaging-14.1.4\android\build\poms\pom-default.xml'.
* 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 14s
Gradle task assembleAarDebug failed with exit code 1.
The gradle files are automatically generated when flutter build command is executed. There seems to be compatibility issues related to firebase_messaging package. When I remove this package from pubspec.yaml, everything works fine.
This issue is not seen when flutter app project is created.
I am facing following error in console when running in release mode.
C:\Users\Bilal Saeed\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\google_maps_flutter-2.1.0\android\src\main\java\io\flutter\plugins\googlemaps\Googl
eMapsPlugin.java:19: error: cannot find symbol
import io.flutter.embedding.engine.plugins.lifecycle.FlutterLifecycleAdapter;
^
symbol: class FlutterLifecycleAdapter
location: package io.flutter.embedding.engine.plugins.lifecycle
C:\Users\Bilal Saeed\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\google_maps_flutter-2.1.0\android\src\main\java\io\flutter\plugins\googlemaps\Googl
eMapsPlugin.java:92: error: cannot find symbol
lifecycle = FlutterLifecycleAdapter.getActivityLifecycle(binding);
^
symbol: variable FlutterLifecycleAdapter
location: class GoogleMapsPlugin
Note: C:\Users\Bilal Saeed\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\google_maps_flutter-2.1.0\android\src\main\java\io\flutter\plugins\googlemaps
\Convert.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: C:\Users\Bilal Saeed\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\google_maps_flutter-2.1.0\android\src\main\java\io\flutter\plugins\googlemaps
\TileProviderController.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
2 errors
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':google_maps_flutter:compileReleaseJavaWithJavac'.
> Compilation failed; see the compiler error output 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 3m 14s
Running Gradle task 'assembleRelease'... 195.8s
Gradle task assembleRelease failed with exit code 1
What I have tried so far.
Added this line to gradle.properties.
org.gradle.jvmargs=-Xmx4608m
In Android Studio
File > Invalidate Caches/Restart...
Deleted the complete pub_cache folder.
Restarted my Android Studio.
Ran flutter clean, flutter pub get, flutter upgrade.
Ran flutter pub cache repair command also.
But no solution worked.
What worked for me might help some one else.
1. Delete .gradle file present in android folder of project.
2. Update classpath in project level build.gradle file by hovering over it to the latest version.
3. Upgraded distribution URL in gradle-wrapper.properties
4. Clicked File/Invalidate Caches & restart option.
And it started to release my app once again.
I am trying to build an apk of my flutter app, but when I run this command
flutter build apk
I encounter the following error;
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':clipboard_manager:verifyReleaseResources'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> Android resource linking failed
/home/username/.gradle/caches/transforms-2/files-2.1/a528b13ac93e64cafa3d0480e2c93207/core-1.1.0/res/values/values.xml:142:5-173:25: AAPT: error: resource android:attr/fontVariationSettings not found.
/home/username/.gradle/caches/transforms-2/files-2.1/a528b13ac93e64cafa3d0480e2c93207/core-1.1.0/res/values/values.xml:142:5-173: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 9s
Running Gradle task 'assembleRelease'...
Running Gradle task 'assembleRelease'... Done 10.1s
The build failed likely due to AndroidX incompatibilities in a plugin. The tool is about to try using Jetifier to solve the
incompatibility.
Building plugin clipboard_manager...
Running Gradle task 'assembleAarRelease'...
Running Gradle task 'assembleAarRelease'... Done 741ms
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'clipboard_manager'.
> SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.
* 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 0s
The plugin clipboard_manager could not be built due to the issue above.
I am getting the flutter pub outdated --mode=null-safety
Package Name Current Upgradable Resolvable Latest
direct dependencies:
clipboard_manager ✗0.0.4 ✗0.0.4 ✗0.0.4 ✗0.0.4
cupertino_icons ✗0.1.3 ✗0.1.3 ✓1.0.3 ✓1.0.3
dio ✗3.0.10 ✗3.0.10 ✓4.0.0 ✓4.0.0
flutter_circular_chart ✗0.1.0 ✗0.1.0 ✗0.1.0 ✗0.1.0
flutter_secure_storage ✗3.3.5 ✗3.3.5 ✓4.2.0 ✓4.2.0
flutter_svg ✗0.19.3 ✗0.19.3 ✓0.22.0 ✓0.22.0
http ✗0.12.2 ✗0.12.2 ✓0.13.3 ✓0.13.3
image_picker ✗0.6.5+3 ✗0.6.5+3 ✓0.8.0+3 ✓0.8.0+3
logger ✗0.9.4 ✗0.9.4 ✓1.0.0 ✓1.0.0
provider ✗4.3.3 ✗4.3.3 ✓5.0.0 ✓5.0.0
8 dependencies are constrained to versions that are older than a resolvable version.
To update these dependencies, edit pubspec.yaml, or run `flutter pub upgrade --null-safety`.
I have searched for it, and they told to change the flutter.sdk, to home.username/Android/Sdk I did this, but after running the buiuld command I got home/lechat/snap/flutter/common/flutter in flutter.sdk in local.properties.
I do not know what the problem actually is. Kindly halp me with this problem. If you any other information I am ready to share it.
I have also followed this question, related problem
but still getting the same error.
Check this similar question there are multiple answers and all of them seem to get the work done, only one of them uses clipboard_manager though.
I m using This package to get download path in android which work well.
By using this Package I get /storage/emulated/0/Download which I want.
Problem: When I ran flutter run --release it throws an error.
Launching lib\main.dart on SM J700F in release mode...
Running Gradle task 'assembleRelease'...
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':downloads_path_provider:verifyReleaseResources'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> Android resource linking failed
C:\Users\Sandeep Sharma\.gradle\caches\transforms-2\files-2.1\56f020e9c27d6a807cc1a74760f6e28d\core-1.0.0\res\values\values.xml:57:5-88:25: AAPT: error: resource android:attr/fontVa
riationSettings not found.
C:\Users\Sandeep Sharma\.gradle\caches\transforms-2\files-2.1\56f020e9c27d6a807cc1a74760f6e28d\core-1.0.0\res\values\values.xml:57:5-88:25: AAPT: error: resource android:attr/ttcInd
ex 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 2m 34s
Running Gradle task 'assembleRelease'...
Running Gradle task 'assembleRelease'... Done 158.0s (!)
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 cloud_firestore...
The plugin cloud_firestore could not be built due to the issue above.
Running Gradle task 'assembleAarRelease'...
if This can't be solved then suggest being how to get this path /storage/emulated/0/Download or another way around.
Update: I just saw Repo of Downloads_path_provider which says
This plugin has lots of inconsistencies and should no longer be used. Feel free to fork and tweak it.
what should I use to get this path /storage/emulated/0/Download.
Thanks.
instead use the ext_storage plugin:
ExtStorage.getExternalStoragePublicDirectory(ExtStorage.DIRECTORY_DOWNLOADS);
I had the same issue and worked for me.
You have to use the official package provided by the flutter known as path_provide and use the getDownloadsDirectory() method to get the path.
I can successfully build and run a fresh new flutter project. But when I add both image_cropper: ^1.0.0 and contacts_service: ^0.2.4 packages to pubspec.yaml and run flutter packages get, I cannot build the project anymore, and get this build error:
D8: Program type already present: android.support.v4.app.INotificationSideChannel
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\2.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\3.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\4.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\5.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\6.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\7.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\8.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\9.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\10.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\11.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\12.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\13.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\14.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\15.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\16.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\17.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\18.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\19.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\20.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\21.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\22.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\23.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\24.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\25.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\26.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\27.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\28.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\29.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\30.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\31.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\32.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\33.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\34.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\35.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\36.jar
Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes.
Program type already present: android.support.v4.app.INotificationSideChannel
* 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 1m 19s
*******************************************************************************************
The Gradle failure may have been because of AndroidX incompatibilities in this Flutter app.
See https:///CP92wY for more information on the problem and how to fix it.
*******************************************************************************************
Finished with error: Gradle task assembleDebug failed with exit code 1
I do not understand this error very well, but it seems that there is a naming conflict between these two packages (because of duplicate_classes in the error text). Is there any workaround for this?
Note that this error does not happen with any other pair of packages for me.
In build.gradle defaultConfig add multiDexEnabled true
This was an Android X compatibility issue. I could get it fixed by following the steps mentioned here, but in summary:
First make sure that compileSdkVersion is at least 28 in app/build.gradle. This property controls the version of the Android SDK that Gradle uses to build your APK. It doesn’t affect the minimum SDK version that your app can run on.
Right click on android directory of flutter project and open it using this menu: Flutter > Open android module in android studio
In the newly opened project, from menus select Refactor > Migrate to AdnroidX
Close the project and open your flutter project again.