Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

APK Build fails with Flutter 1.7.0 or even v.1.5+ #438

Open
DewangS opened this issue Jun 5, 2019 · 9 comments
Open

APK Build fails with Flutter 1.7.0 or even v.1.5+ #438

DewangS opened this issue Jun 5, 2019 · 9 comments

Comments

@DewangS
Copy link

DewangS commented Jun 5, 2019

see below ...

Initializing gradle...                                              0.8s
Resolving dependencies...                                           1.4s
**Note: Some input files use or override a deprecated API.                
Note: Recompile with -Xlint:deprecation for details.                    
Note: /Users/dev/.pub-cache/hosted/pub.dartlang.org/flutter_webview_plugin-0.3.5/android/src/main/java/com/flutter_webview_plugin/WebviewManager.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.                      
D8: Program type already present: android.support.v4.os.ResultReceiver$1**
                                                                        
FAILURE: Build failed with an exception.                                
                                                                        
* What went wrong:                                                      
Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForRelease'.
> com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: /Users/dewang/wsumobileapps/western-sydney-mobile-app/build/app/intermediates/transforms/dexBuilder/release/31.jar, /Users/dewang/wsumobileapps/western-sydney-mobile-app/build/app/intermediates/transforms/dexBuilder/release/32.jar, /Users/dewang/wsumobileapps/western-sydney-mobile-app/build/app/intermediates/transforms/dexBuilder/release/33.jar, /Users/dewang/wsumobileapps/western-sydney-mobile-app/build/app/intermediates/transforms/dexBuilder/release/34.jar, /Users/dewang/wsumobileapps/western-sydney-mobile-app/build/app/intermediates/transforms/dexBuilder/release/35.jar, /Users/dewang/wsumobileapps/western-sydney-mobile-app/build/app/intermediates/transforms/dexBuilder/release/36.jar, /Users/dewang/wsumobileapps/western-sydney-mobile-app/build/app/intermediates/transforms/dexBuilder/release/37.jar, /Users/dewang/wsumobileapps/western-sydney-mobile-app/build/app/intermediates/transforms/dexBuilder/release/38.jar, /Users/dewang/wsumobileapps/western-sydney-mobile-app/build/app/intermediates/transforms/dexBuilder/release/39.jar, /Users/dewang/wsumobileapps/western-sydney-mobile-app/build/app/intermediates/transforms/dexBuilder/release/40.jar, /Users/dewang/wsumobileapps/western-sydney-mobile-app/build/app/intermediates/transforms/dexBuilder/release/41.jar, /Users/dewang/wsumobileapps/western-sydney-mobile-app/build/app/intermediates/transforms/dexBuilder/release/42.jar, /Users/dewang/wsumobileapps/western-sydney-mobile-app/build/app/intermediates/transforms/dexBuilder/release/43.jar, /Users/dewang/wsumobileapps/western-sydney-mobile-app/build/app/intermediates/transforms/dexBuilder/release/44.jar, /Users/dewang/wsumobileapps/western-sydney-mobile-app/build/app/intermediates/transforms/dexBuilder/release/45.jar, /Users/dewang/wsumobileapps/western-sydney-mobile-app/build/app/intermediates/transforms/dexBuilder/release/46.jar, /Users/dewang/wsumobileapps/western-sydney-mobile-app/build/app/intermediates/transforms/dexBuilder/release/47.jar, /Users/dewang/wsumobileapps/western-sydney-mobile-app/build/app/intermediates/transforms/dexBuilder/release/48.jar, /Users/dewang/wsumobileapps/western-sydney-mobile-app/build/app/intermediates/transforms/dexBuilder/release/49.jar, /Users/dewang/wsumobileapps/western-sydney-mobile-app/build/app/intermediates/transforms/dexBuilder/release/50.jar, /Users/dewang/wsumobileapps/western-sydney-mobile-app/build/app/intermediates/transforms/dexBuilder/release/51.jar, /Users/dewang/wsumobileapps/western-sydney-mobile-app/build/app/intermediates/transforms/dexBuilder/release/52.jar, /Users/dewang/wsumobileapps/western-sydney-mobile-app/build/app/intermediates/transforms/dexBuilder/release/53.jar, /Users/dewang/wsumobileapps/western-sydney-mobile-app/build/app/intermediates/transforms/dexBuilder/release/54.jar, /Users/dewang/wsumobileapps/western-sydney-mobile-app/build/app/intermediates/transforms/dexBuilder/release/55.jar, /Users/dewang/wsumobileapps/western-sydney-mobile-app/build/app/intermediates/transforms/dexBuilder/release/56.jar, /Users/dewang/wsumobileapps/western-sydney-mobile-app/build/app/intermediates/transforms/dexBuilder/release/57.jar, /Users/dewang/wsumobileapps/western-sydney-mobile-app/build/app/intermediates/transforms/dexBuilder/release/58.jar, /Users/dewang/wsumobileapps/western-sydney-mobile-app/build/app/intermediates/transforms/dexBuilder/release/59.jar, /Users/dewang/wsumobileapps/western-sydney-mobile-app/build/app/intermediates/transforms/dexBuilder/release/60.jar, /Users/dewang/wsumobileapps/western-sydney-mobile-app/build/app/intermediates/transforms/dexBuilder/release/61.jar, /Users/dewang/wsumobileapps/western-sydney-mobile-app/build/app/intermediates/transforms/dexBuilder/release/62.jar, /Users/dewang/wsumobileapps/western-sydney-mobile-app/build/app/intermediates/transforms/dexBuilder/release/63.jar, /Users/dewang/wsumobileapps/western-sydney-mobile-app/build/app/intermediates/transforms/dexBuilder/release/64.jar, /Users/dewang/wsumobileapps/western-sydney-mobile-app/build/app/intermediates/transforms/dexBuilder/release/65.jar, /Users/dewang/wsumobileapps/western-sydney-mobile-app/build/app/intermediates/transforms/dexBuilder/release/66.jar, /Users/dewang/wsumobileapps/western-sydney-mobile-app/build/app/intermediates/transforms/dexBuilder/release/67.jar, /Users/dewang/wsumobileapps/western-sydney-mobile-app/build/app/intermediates/transforms/dexBuilder/release/68.jar, /Users/dewang/wsumobileapps/western-sydney-mobile-app/build/app/intermediates/transforms/dexBuilder/release/69.jar, /Users/dewang/wsumobileapps/western-sydney-mobile-app/build/app/intermediates/transforms/dexBuilder/release/70.jar, /Users/dewang/wsumobileapps/western-sydney-mobile-app/build/app/intermediates/transforms/dexBuilder/release/71.jar, /Users/dewang/wsumobileapps/western-sydney-mobile-app/build/app/intermediates/transforms/dexBuilder/release/72.jar, /Users/dewang/wsumobileapps/western-sydney-mobile-app/build/app/intermediates/transforms/dexBuilder/release/73.jar, /Users/dewang/wsumobileapps/western-sydney-mobile-app/build/app/intermediates/transforms/dexBuilder/release/74.jar, /Users/dewang/wsumobileapps/western-sydney-mobile-app/build/app/intermediates/transforms/dexBuilder/release/75.jar, /Users/dewang/wsumobileapps/western-sydney-mobile-app/build/app/intermediates/transforms/dexBuilder/release/76.jar, /Users/dewang/wsumobileapps/western-sydney-mobile-app/build/app/intermediates/transforms/dexBuilder/release/77.jar, /Users/dewang/wsumobileapps/western-sydney-mobile-app/build/app/intermediates/transforms/dexBuilder/release/78.jar, /Users/dewang/wsumobileapps/western-sydney-mobile-app/build/app/intermediates/transforms/dexBuilder/release/79.jar, /Users/dewang/wsumobileapps/western-sydney-mobile-app/build/app/intermediates/transforms/dexBuilder/release/80.jar, /Users/dewang/wsumobileapps/western-sydney-mobile-app/build/app/intermediates/transforms/dexBuilder/release/81.jar, /Users/dewang/wsumobileapps/western-sydney-mobile-app/build/app/intermediates/transforms/dexBuilder/release/82.jar, /Users/dewang/wsumobileapps/western-sydney-mobile-app/build/app/intermediates/transforms/dexBuilder/release/83.jar, /Users/dewang/wsumobileapps/western-sydney-mobile-app/build/app/intermediates/transforms/dexBuilder/release/84.jar, /Users/dewang/wsumobileapps/western-sydney-mobile-app/build/app/intermediates/transforms/dexBuilder/release/85.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 49s                                                     
Running Gradle task 'assembleRelease'...                                
Running Gradle task 'assembleRelease'... Done                      49.7s
*******************************************************************************************
The Gradle failure may have been because of AndroidX incompatibilities in this Flutter app.
See https://goo.gl/CP92wY for more information on the problem and how to fix it.
*******************************************************************************************
Gradle task assembleRelease failed with exit code 1
@adammesa
Copy link

adammesa commented Jun 6, 2019

Did you try going through the details listed on AndroidX incompatibilities? https://goo.gl/CP92wY

If that's not the issue, could you try printing the stacktrace?

@DewangS
Copy link
Author

DewangS commented Jun 6, 2019

Hi @muffinjello
I did try the AndroidX migration just to find that Android studio detected no AndroixX usage so, that warning must be misleading from Flutter. Finally I have managed to make it work using the below approach and honestly I am not happy with this plugin conflicts with required SDKs etc. While I understand that Flutter is relatively new and these plugins are generous contributions from the Flutter family, they need to ensure that any Flutter version upgrades don't break things line this.

Ok, the core issue came down to 2 plugins(and esp. these versions) which I was using ...

flutter_webview_plugin: ^0.3.5
google_maps_flutter: ^0.5.16

so, if I just use the flutter_webview_plugin: ^0.3.5, I get the below errors and the APK build fails ..

Initializing gradle... 0.7s
Resolving dependencies... 1.6s
D8: Program type already present: android.support.v4.os.ResultReceiver$1

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForRelease'.

com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:

if I use just the flutter_webview_plugin: ^0.3.5 . ... It complies with below warning BUT does successfully build the APK

Initializing gradle... 1.2s
Resolving dependencies... 8.2s
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: /Users/dewang/.pub-cache/hosted/pub.dartlang.org/flutter_webview_plugin-0.3.5/android/src/main/java/com/flutter_webview_plugin/WebviewManager.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Running Gradle task 'assembleRelease'...
Running Gradle task 'assembleRelease'... Done 38.6s
Built build/app/outputs/apk/release/app-release.apk (6.2MB).

If I just use google_maps_flutter: ^0.5.16, I get the below warnings BUT it does end up building APK

Initializing gradle... 0.8s
Resolving dependencies... 1.3s
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Running Gradle task 'assembleRelease'...
Running Gradle task 'assembleRelease'... Done 27.2s
Built build/app/outputs/apk/release/app-release.apk (6.0MB).

I even tried to use webview_flutter: ^0.3.9+1 it builds the APK with below warnings ..

Initializing gradle... 0.7s
Resolving dependencies... 1.5s
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Running Gradle task 'assembleRelease'...
Running Gradle task 'assembleRelease'... Done 25.7s
Built build/app/outputs/apk/release/app-release.apk (5.3MB).

...BUT... if I have 2 plugins i.e. google_maps_flutter: ^0.5.16 and webview_flutter: ^0.3.9+1, I again get the same BIG FAT error about DEX archives(see below) and the build fails.

Initializing gradle... 0.8s
Resolving dependencies... 1.4s
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation 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:transformDexArchiveWithExternalLibsDexMergerForRelease'.

com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:

So, in a nutshell the google_maps_flutter ^0.5.16 conflicts with any of the other 2 plugins (an may be a few others which I don't use). Hope this clarifies things

@zekiegitimcom
Copy link

zekiegitimcom commented Jun 22, 2019

I have the same issue.
When i activate cloud_firestore plugin, then i get this error.
When i remove that plugin, then it works.

Flutter: 1.5.4-hotfix.2

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':app:transformClassesWithMultidexlistForDebug'.

com.android.build.api.transform.TransformException: Error while generating the main dex list.

  • 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

BU�LD FAILED in 3s
Gradle task assembleDebug failed with exit code 1

@charafau
Copy link
Collaborator

Did you change your dependencies to AndroidX ones?

@DewangS
Copy link
Author

DewangS commented Jun 26, 2019

@charafau FYI...The AndroidX dependency errors in Flutter are misleading as in my case I even tried to open the project in Android Studio and selected auto migrate to AndroidX, it came back saying no AndroidX dependencies found.

@neverPick
Copy link

Finaly fixed it by flutter config --no-enable-build-plugin-as-aar with flutter 1.7.8. Just Disabling the new build flag.

@josejbarneto
Copy link

Finaly fixed it by flutter config --no-enable-build-plugin-as-aar with flutter 1.7.8. Just Disabling the new build flag.

Im trying the command and doesnt work

flutter config --no-enable-build-plugin-as-aar

Could not find an option named "enable-build-plugin-as-aar".


Run 'flutter -h' (or 'flutter <command> -h') for available flutter commands and options.

@kencode
Copy link

kencode commented Aug 7, 2019

I have the same issue.

@vicgrad
Copy link

vicgrad commented Aug 12, 2019

I am also stuck with this. Debug builds work, release builds don't work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants