flutter build error - merging dex archives - android

I upgraded flutter today (flutter update) and the packages (flutter packages update) and since my app does not build.
This is the output I get (after trying to change the sdk from 27 to 28 and clean)
I would appreciate your help.
Launching lib\main.dart on in debug mode...
Initializing gradle...
Resolving dependencies...
Gradle task 'assembleDebug'...
*********************************************************
WARNING: This version of device_info will break your Android build if it or its dependencies aren't compatible with AndroidX.
See hfor more information on the problem and how to fix it.
This warning prints for all Android build failures. The real root cause of the error may be unrelated.
*********************************************************
D8: Program type already present: android.support.v4.app.INotificationSideChannel$Stub$Proxy
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: C:\Users\X\Documents\Projects\git\XX\app\build\app\intermediates\transforms\dexBuilder\debug\271.jar, C:\Users\X\Documents\Projects\git\XX\app\build\app\intermediates\transforms\dexBuilder\debug\272.jar, C:\Users\X\Documents\Projects\git\XX\app\build\app\intermediates\transforms\dexBuilder\debug\273.jar, C:\Users\X\Documents\Projects\git\XX\app\build\app\intermediates\transforms\dexBuilder\debug\274.jar, C:\Users\X\Documents\Projects\git\XX\app\build\app\intermediates\transforms\dexBuilder\debug\275.jar, C:\Users\X\Documents\Projects\git\XX\app\build\app\intermediates\transforms\dexBuilder\debug\276.jar, C:\Users\X\Documents\Projects\git\XX\app\build\app\intermediates\transforms\dexBuilder\debug\277.jar, C:\Users\X\Documents\Projects\git\XX\app\build\app\intermediates\transforms\dexBuilder\debug\278.jar, C:\Users\X\Documents\Projects\git\XX\app\build\app\intermediates\transforms\dexBuilder\debug\279.jar, C:\Users\X\Documents\Projects\git\XX\app\build\app\intermediates\transforms\dexBuilder\debug\280.jar, C:\Users\X\Documents\Projects\git\XX\app\build\app\intermediates\transforms\dexBuilder\debug\281.jar, C:\Users\X\Documents\Projects\git\XX\app\build\app\intermediates\transforms\dexBuilder\debug\282.jar, C:\Users\X\Documents\Projects\git\XX\app\build\app\intermediates\transforms\dexBuilder\debug\283.jar, C:\Users\X\Documents\Projects\git\XX\app\build\app\intermediates\transforms\dexBuilder\debug\284.jar, C:\Users\X\Documents\Projects\git\XX\app\build\app\intermediates\transforms\dexBuilder\debug\285.jar, C:\Users\X\Documents\Projects\git\XX\app\build\app\intermediates\transforms\dexBuilder\debug\286.jar, C:\Users\X\Documents\Projects\git\XX\app\build\app\intermediates\transforms\dexBuilder\debug\287.jar, C:\Users\X\Documents\Projects\git\XX\app\build\app\intermediates\transforms\dexBuilder\debug\288.jar, C:\Users\X\Documents\Projects\git\XX\app\build\app\intermediates\transforms\dexBuilder\debug\289.jar, C:\Users\X\Documents\Projects\git\XX\app\build\app\intermediates\transforms\dexBuilder\debug\290.jar, C:\Users\X\Documents\Projects\git\XX\app\build\app\intermediates\transforms\dexBuilder\debug\291.jar, C:\Users\X\Documents\Projects\git\XX\app\build\app\intermediates\transforms\dexBuilder\debug\292.jar, C:\Users\X\Documents\Projects\git\XX\app\build\app\intermediates\transforms\dexBuilder\debug\293.jar, C:\Users\X\Documents\Projects\git\XX\app\build\app\intermediates\transforms\dexBuilder\debug\294.jar, C:\Users\X\Documents\Projects\git\XX\app\build\app\intermediates\transforms\dexBuilder\debug\295.jar, C:\Users\X\Documents\Projects\git\XX\app\build\app\intermediates\transforms\dexBuilder\debug\296.jar, C:\Users\X\Documents\Projects\git\XX\app\build\app\intermediates\transforms\dexBuilder\debug\297.jar, C:\Users\X\Documents\Projects\git\XX\app\build\app\intermediates\transforms\dexBuilder\debug\298.jar, C:\Users\X\Documents\Projects\git\XX\app\build\app\intermediates\transforms\dexBuilder\debug\299.jar, C:\Users\X\Documents\Projects\git\XX\app\build\app\intermediates\transforms\dexBuilder\debug\300.jar, C:\Users\X\Documents\Projects\git\XX\app\build\app\intermediates\transforms\dexBuilder\debug\301.jar, C:\Users\X\Documents\Projects\git\XX\app\build\app\intermediates\transforms\dexBuilder\debug\302.jar, C:\Users\X\Documents\Projects\git\XX\app\build\app\intermediates\transforms\dexBuilder\debug\303.jar, C:\Users\X\Documents\Projects\git\XX\app\build\app\intermediates\transforms\dexBuilder\debug\304.jar, C:\Users\X\Documents\Projects\git\XX\app\build\app\intermediates\transforms\dexBuilder\debug\305.jar, C:\Users\X\Documents\Projects\git\XX\app\build\app\intermediates\transforms\dexBuilder\debug\306.jar, C:\Users\X\Documents\Projects\git\XX\app\build\app\intermediates\transforms\dexBuilder\debug\307.jar, C:\Users\X\Documents\Projects\git\XX\app\build\app\intermediates\transforms\dexBuilder\debug\308.jar, C:\Users\X\Documents\Projects\git\XX\app\build\app\intermediates\transforms\dexBuilder\debug\309.jar, C:\Users\X\Documents\Projects\git\XX\app\build\app\intermediates\transforms\dexBuilder\debug\310.jar, C:\Users\X\Documents\Projects\git\XX\app\build\app\intermediates\transforms\dexBuilder\debug\311.jar, C:\Users\X\Documents\Projects\git\XX\app\build\app\intermediates\transforms\dexBuilder\debug\312.jar, C:\Users\X\Documents\Projects\git\XX\app\build\app\intermediates\transforms\dexBuilder\debug\313.jar, C:\Users\X\Documents\Projects\git\XX\app\build\app\intermediates\transforms\dexBuilder\debug\314.jar, C:\Users\X\Documents\Projects\git\XX\app\build\app\intermediates\transforms\dexBuilder\debug\315.jar, C:\Users\X\Documents\Projects\git\XX\app\build\app\intermediates\transforms\dexBuilder\debug\316.jar, C:\Users\X\Documents\Projects\git\XX\app\build\app\intermediates\transforms\dexBuilder\debug\317.jar, C:\Users\X\Documents\Projects\git\XX\app\build\app\intermediates\transforms\dexBuilder\debug\318.jar, C:\Users\X\Documents\Projects\git\XX\app\build\app\intermediates\transforms\dexBuilder\debug\319.jar, C:\Users\X\Documents\Projects\git\XX\app\build\app\intermediates\transforms\dexBuilder\debug\320.jar, C:\Users\X\Documents\Projects\git\XX\app\build\app\intermediates\transforms\dexBuilder\debug\321.jar, C:\Users\X\Documents\Projects\git\XX\app\build\app\intermediates\transforms\dexBuilder\debug\322.jar, C:\Users\X\Documents\Projects\git\XX\app\build\app\intermediates\transforms\dexBuilder\debug\323.jar, C:\Users\X\Documents\Projects\git\XX\app\build\app\intermediates\transforms\dexBuilder\debug\324.jar, C:\Users\X\Documents\Projects\git\XX\app\build\app\intermediates\transforms\dexBuilder\debug\325.jar, C:\Users\X\Documents\Projects\git\XX\app\build\app\intermediates\transforms\dexBuilder\debug\326.jar, C:\Users\X\Documents\Projects\git\XX\app\build\app\intermediates\transforms\dexBuilder\debug\327.jar, C:\Users\X\Documents\Projects\git\XX\app\build\app\intermediates\transforms\dexBuilder\debug\328.jar, C:\Users\X\Documents\Projects\git\XX\app\build\app\intermediates\transforms\dexBuilder\debug\329.jar, C:\Users\X\Documents\Projects\git\XX\app\build\app\intermediates\transforms\dexBuilder\debug\330.jar, C:\Users\X\Documents\Projects\git\XX\app\build\app\intermediates\transforms\dexBuilder\debug\331.jar, C:\Users\X\Documents\Projects\git\XX\app\build\app\intermediates\transforms\dexBuilder\debug\332.jar, C:\Users\X\Documents\Projects\git\XX\app\build\app\intermediates\transforms\dexBuilder\debug\333.jar, C:\Users\X\Documents\Projects\git\XX\app\build\app\intermediates\transforms\dexBuilder\debug\334.jar, C:\Users\X\Documents\Projects\git\XX\app\build\app\intermediates\transforms\dexBuilder\debug\335.jar, C:\Users\X\Documents\Projects\git\XX\app\build\app\intermediates\transforms\dexBuilder\debug\336.jar, C:\Users\X\Documents\Projects\git\XX\app\build\app\intermediates\transforms\dexBuilder\debug\337.jar, C:\Users\X\Documents\Projects\git\XX\app\build\app\intermediates\transforms\dexBuilder\debug\338.jar, C:\Users\X\Documents\Projects\git\XX\app\build\app\intermediates\transforms\dexBuilder\debug\339.jar, C:\Users\X\Documents\Projects\git\XX\app\build\app\intermediates\transforms\dexBuilder\debug\340.jar, C:\Users\X\Documents\Projects\git\XX\app\build\app\intermediates\transforms\dexBuilder\debug\341.jar, C:\Users\X\Documents\Projects\git\XX\app\build\app\intermediates\transforms\dexBuilder\debug\342.jar
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 37s
Finished with error: Gradle task assembleDebug failed with exit code 1

Original answer by Yuri Misyac
Enable multidex.
Open {your flutter project}/android/app/build.gradle and add following lines.
defaultConfig {
...
multiDexEnabled true // Add this line
}
and
dependencies {
...
implementation 'com.android.support:multidex:1.0.3' // Add this line
}
Migrate to AndroidX.
Open {your flutter project}/android/gradle.properties and add following lines.
...
android.useAndroidX=true // Add this line
android.enableJetifier=true //Add this line
More info:
Original answer (Check this if it still doesn't work)
Enable Multidex
Migrating to AndroidX

Related

Why I am getting this error after Flutter Run?

I am getting the following Build failed with exception after I run my flutter project.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:checkDebugDuplicateClasses'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckDuplicatesRunnable
> Duplicate class com.google.android.exoplayer2.ui.DownloadNotificationHelper found in modules jetified-exoplayer-core-2.17.0-runtime (com.google.android.exoplayer:exoplayer-core:2.17.0) and jetified-exoplayer-ui-2.15.1-runtime (com.google.android.exoplayer:exoplayer-ui:2.15.1)
Go to the documentation to learn how to Fix dependency resolution errors.
* 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 26s
Running Gradle task 'assembleDebug'... 208.9s
Exception: Gradle task assembleDebug failed with exit code 1
I am currently using Flutter's latest version that is Version 2.10.1. Also in my project, I used the 'better_player' pub package.
Please give me a solution to this.
Add following dependency in app/build.gradle in dependencies at the end of the file -
implementation 'com.google.android.exoplayer:exoplayer:2.17.0'
Example -
dependencies {
...
implementation 'com.google.android.exoplayer:exoplayer:2.17.0'
}
First : if you are using video_player
add this line in your app/build.gradle
implementation 'com.google.android.exoplayer:exoplayer:2.17.1'
Second : if you are using better_player
add this line in your app/build.gradle
implementation 'com.google.android.exoplayer:exoplayer:2.15.0'
Third : if you are using the both video_player & better_player
you should downgraded video_player version to 2.1.12 in pubspec.yaml

Problems reading data from Binary store .I tried lots of solution but not working please help me

'''Launching lib/main.dart on vivo 1907 in debug mode...
Running Gradle task 'assembleDebug'...
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':onesignal_flutter:generateDebugRFile'.
In project 'app' a resolved Google Play services library dependency depends on another at an exact version (e.g. "[10.2.
1, 17.3.99]", but isn't being resolved to that version. Behavior exhibited by the library will be unknown.
Dependency failing: com.onesignal:OneSignal:3.16.0 -> com.google.firebase:firebase-messaging#[10.2.1, 17.3.99], but fire
base-messaging version was 17.3.4.
The following dependencies are project dependencies that are direct or have transitive dependencies that lead to the art
ifact with the issue.
-- Project 'app' depends on project 'onesignal_flutter' which depends onto com.google.firebase:firebase-messaging#{stric
tly 17.3.4}
-- Project 'app' depends on project 'onesignal_flutter' which depends onto com.onesignal:OneSignal#{strictly 3.16.0}
-- Project 'app' depends on project 'onesignal_flutter' which depends onto com.onesignal:OneSignal#3.16.0
For extended debugging info execute Gradle from the command line with ./gradlew --info :app:assembleDebug to see the dep
endency paths to the artifact. This error message came from the google-services Gradle plugin, report issues at https://
github.com/google/play-services-plugins and disable by adding "googleServices { disableVersionCheck = true }" to your bu
ild.gradle file.
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 51s
Exception: Gradle task assembleDebug failed with exit code 1
'''

Flutter build failed with D8: Program type already present

I am developing a flutter app.
I found a sample flutter project so folk it.
But the project... build failed with below log message.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:preDebugBuild'.
> Android dependency 'androidx.core:core' has different version for the compile (1.0.0) and runtime (1.0.1) classpath. You should manually set the same version via DependencyResolution
* 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 Gradle failure may have been because of AndroidX incompatibilities in this Flutter app.
See https://flutter.dev/docs/development/packages-and-plugins/androidx-compatibility for more information on the problem and how to fix it.
*******************************************************************************************
Finished with error: Gradle task assembleDebug failed with exit code 1
The project is not special.
The android part, there are no other modifications.
It is totally same with the "new flutter project'.
I tried something:
Migration to AndroidX
This is failed with error popup. I tried to migration using "refactor > migration to android x", but it shows error popup.
The error popup said to me use compilesdkversion at least 28.
But I already use 28.. what should I do?......
change gradle version from 3.2.1 to 3.3.2.
But build failed with different log
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
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:
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
I don't know what should i do...
It make me to tired...
I just want to coding...
I resolve this issue following this link: https://flutter.dev/docs/development/packages-and-plugins/androidx-compatibility
There is 2 migration guide.
Recommended
Not Recommended
In my case, 'Recommended' solution doesn't work...
But, 'Not recommended' solution works...
...
It's not easy...
I tried this two lines of code
flutter clean and then
flutter run

Already updated compileSdkVersion to 28 after migrating to AndroidX, but still getting gradle error about fontVariationSettings and ttcIndex

Migrating to AndroidX includes new attributes fontVariationSettings and ttcIndex. I've tried migrating a project (a Flutter plugin), but get the error below when doing the gradle build. Many users have had the same gradle error as me, but unlike them, I've already
upgraded my compileSdkVersion to 28 in my build.gradle
added android.useAndroidX=true and android.enableJetifier=true in gradle.properties
reset the gradle cache through Android Studio (Invalidate Caches/Restart)
My console output:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:processDebugResources'.
> Android resource linking failed
/Users/davidmccoy/.gradle/caches/transforms-1/files-1.1/core-1.0.0-beta01.aar/f004b9e22a129b2d333d02089203fb0d/res/values/values.xml:89:5-125:25: AAPT: error: resource android:attr/fontVariationSettings not found.
/Users/davidmccoy/.gradle/caches/transforms-1/files-1.1/core-1.0.0-beta01.aar/f004b9e22a129b2d333d02089203fb0d/res/values/values.xml:89:5-125:25: AAPT: error: resource android:attr/ttcIndex not found.
error: failed linking references.
* 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 1s
*******************************************************************************************
The Gradle failure may have been because of AndroidX incompatibilities in this Flutter app.
See https://flutter.dev/docs/development/packages-and-plugins/androidx-compatibility for more information on the problem and how to fix it.
*******************************************************************************************
Gradle task assembleDebug failed with exit code 1
Turns out I had another Android project that I had included in my Flutter application that had not yet been upgraded to AndroidX. So I upgraded that project, and the problem was solved.

Android Studio Build Error Execution Failure

I'm a student trying to use Android Studio and as shown below, I'm having errors when I try to build why is this happening? Also, how can I fix it?
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:mergeDebugResources'.
> Error: java.util.concurrent.ExecutionException:
com.android.builder.internal.aapt.v2.Aapt2Exception: AAPT2 error: check logs
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 4s
9 actionable tasks: 1 executed, 8 up-to-date
P.S: I'm not sure what the thing that says in the try section means.
Error:com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
see this link, Aapt2 is enabled by default to speed up builds.
Update your gradle version and this error should disappear, alternatively disable aapt2, but prefer to upgrade the gradle version, as just disabeling aapt2 hides the problem, and also slowes down your build.
updating
build.gradle(top level)
buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:3.1.4
}
}
gradle-wrapper.properties
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
alternatively disable it in gradle.properties
android.enableAapt2=false

Categories

Resources