phonegap / phonegap-plugin-push

Register and receive push notifications
MIT License
1.94k stars 1.91k forks source link

Multiple dex files define Landroid/support/v13/view/inputmethod/InputConnectionCompat #2229

Closed jdbriner07 closed 6 years ago

jdbriner07 commented 6 years ago

Expected Behaviour

cordova run android will produce an apk

Actual Behaviour

cordova run android Build fails with exit code 1 (logs below)

Went through and removed and reinstalled each plugin for my app. Build is fine when built without this plugin but fails with it

Reproduce Scenario (including but not limited to)

Has been working fine till this afternoon (2/27/18)

Steps to Reproduce

create a cordova project and add plugin

Platform and Version (eg. Android 5.0 or iOS 9.2.1)

N/A

(Android) What device vendor (e.g. Samsung, HTC, Sony...)

N/A

Cordova CLI version and cordova platform version

cordova --version                                    7.1.0 and 8.0.0
cordova platform version android           6.4.0        

Plugin version

cordova plugin version | grep phonegap-plugin-push   2.1.3

Sample Push Data Payload

N/A

Sample Code that illustrates the problem

N/A

Logs taken while reproducing problem


:transformDexArchiveWithDexMergerForDebugDex: Error converting bytecode to dex:
Cause: com.android.dex.DexException: Multiple dex files define Landroid/support/v13/view/inputmethod/InputConnectionCompat$1;
    UNEXPECTED TOP-LEVEL EXCEPTION:
    com.android.dex.DexException: Multiple dex files define Landroid/support/v13/view/inputmethod/InputConnectionCompat$1;

com.android.dex.DexException: Multiple dex files define Landroid/support/v13/view/inputmethod/InputConnectionCompat$1;
        at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:661)
        at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:616)
        at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:598)
        at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
        at com.android.dx.merge.DexMerger.merge(DexMerger.java:198)
        at com.android.builder.dexing.DexArchiveMergerCallable.call(DexArchiveMergerCallable.java:61)
        at com.android.builder.dexing.DexArchiveMergerCallable.call(DexArchiveMergerCallable.java:36)
        at java.util.concurrent.ForkJoinTask$AdaptedCallable.exec(ForkJoinTask.java:1424)
        at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
        at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
        at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
        at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)
 FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':transformDexArchiveWithDexMergerForDebug'.
> com.android.build.api.transform.TransformException: com.android.dex.DexException: Multiple dex files define Landroid/support/v13/view/inputmethod/InputConnectionCompat$1;

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

* Get more help at https://help.gradle.org

BUILD FAILED in 13s
42 actionable tasks: 40 executed, 2 up-to-date
Error: /Users/jeffreybriner/workspace/StashApp/platforms/android/gradlew: Command failed with exit code 1 Error output:
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Dex: Error converting bytecode to dex:
Cause: com.android.dex.DexException: Multiple dex files define Landroid/support/v13/view/inputmethod/InputConnectionCompat$1;
    UNEXPECTED TOP-LEVEL EXCEPTION:
    com.android.dex.DexException: Multiple dex files define Landroid/support/v13/view/inputmethod/InputConnectionCompat$1;

com.android.dex.DexException: Multiple dex files define Landroid/support/v13/view/inputmethod/InputConnectionCompat$1;
        at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:661)
        at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:616)
        at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:598)
        at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
        at com.android.dx.merge.DexMerger.merge(DexMerger.java:198)
        at com.android.builder.dexing.DexArchiveMergerCallable.call(DexArchiveMergerCallable.java:61)
        at com.android.builder.dexing.DexArchiveMergerCallable.call(DexArchiveMergerCallable.java:36)
        at java.util.concurrent.ForkJoinTask$AdaptedCallable.exec(ForkJoinTask.java:1424)
        at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
        at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
        at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
        at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':transformDexArchiveWithDexMergerForDebug'.
> com.android.build.api.transform.TransformException: com.android.dex.DexException: Multiple dex files define Landroid/support/v13/view/inputmethod/InputConnectionCompat$1;

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

* Get more help at https://help.gradle.org

BUILD FAILED in 13s```
bhandaribhumin commented 6 years ago

@jdbriner07 Facing same issue

mororc commented 6 years ago

Same problem

reineke-fox commented 6 years ago

Same here...also downgrading to 2.1.2 is not helping

vshl commented 6 years ago

Encountering the same issue:

Temporary workaround, edit platforms/android/build.gradle:

below line: apply plugin 'com.android.application'

configurations {
    all*.exclude group: 'com.android.support', module: 'support-v13'
}
macdonst commented 6 years ago

Hey all, this means that some other plugin is including the v13 support library. Can you take a look at what plugins you are using to see which other plugin is including the support library? It seems like they are not doing it correctly.

vshl commented 6 years ago

@macdonst thanks for the reply. Is there a way to check what plugin is using the support library? We haven't updated any of the plugins.

macdonst commented 6 years ago

@vshl you'll need to look at the plugin.xml for all the plugins you include. Using grep would be a good way to do it.

grep -R support-v13 plugins

bhandaribhumin commented 6 years ago

@macdonst only push plugin are using v13

jdbriner07 commented 6 years ago

@macdonst ran

grep -R support-v13 plugins

got

plugins/phonegap-plugin-push/CHANGELOG.md:- Revert pinning of support-v13 [\#983](https://github.com/phonegap/phonegap-plugin-push/issues/983)
plugins/phonegap-plugin-push/plugin.xml:    <framework src="com.android.support:support-v13:26.+"/>
macdonst commented 6 years ago

All, this is weird. Can you run, grep -R support plugins?

flipace commented 6 years ago

@macdonst thanks for the info. i checked the other plugins, and none of them seem to include the v13 support library. the cordova-plugin-camera however uses v4, i removed it - reprepped the platform android and tried to build again, similar issue:

Cause: com.android.dex.DexException: Multiple dex files define Landroid/support/v13/view/inputmethod/InputContentInfoCompat$InputContentInfoCompatImpl;
    UNEXPECTED TOP-LEVEL EXCEPTION:
    com.android.dex.DexException: Multiple dex files define Landroid/support/v13/view/inputmethod/InputContentInfoCompat$InputContentInfoCompatImpl;

com.android.dex.DexException: Multiple dex files define Landroid/support/v13/view/inputmethod/InputContentInfoCompat$InputContentInfoCompatImpl;
    at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:661)
    at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:616)
    at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:598)
    at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
    at com.android.dx.merge.DexMerger.merge(DexMerger.java:198)
    at com.android.builder.dexing.DexArchiveMergerCallable.call(DexArchiveMergerCallable.java:61)
    at com.android.builder.dexing.DexArchiveMergerCallable.call(DexArchiveMergerCallable.java:36)
    at java.util.concurrent.ForkJoinTask$AdaptedCallable.exec(ForkJoinTask.java:1424)
    at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
    at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
    at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
    at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)
 FAILED
40 actionable tasks: 40 executed

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:transformDexArchiveWithDexMergerForArm64Debug'.
> com.android.build.api.transform.TransformException: com.android.dex.DexException: Multiple dex files define Landroid/support/v13/view/inputmethod/InputContentInfoCompat$InputContentInfoCompatImpl;

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

* Get more help at https://help.gradle.org

BUILD FAILED in 23s
Error: /Users/patrickneschkudla/Development/bitbucket.org_ovos/ecosystem/app-ovos-play-micro/cordova/platforms/android/gradlew: Command failed with exit code 1 Error output:
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Dex: Error converting bytecode to dex:
Cause: com.android.dex.DexException: Multiple dex files define Landroid/support/v13/view/inputmethod/InputContentInfoCompat$InputContentInfoCompatImpl;
    UNEXPECTED TOP-LEVEL EXCEPTION:
    com.android.dex.DexException: Multiple dex files define Landroid/support/v13/view/inputmethod/InputContentInfoCompat$InputContentInfoCompatImpl;

com.android.dex.DexException: Multiple dex files define Landroid/support/v13/view/inputmethod/InputContentInfoCompat$InputContentInfoCompatImpl;
    at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:661)
    at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:616)
    at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:598)
    at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
    at com.android.dx.merge.DexMerger.merge(DexMerger.java:198)
    at com.android.builder.dexing.DexArchiveMergerCallable.call(DexArchiveMergerCallable.java:61)
    at com.android.builder.dexing.DexArchiveMergerCallable.call(DexArchiveMergerCallable.java:36)
    at java.util.concurrent.ForkJoinTask$AdaptedCallable.exec(ForkJoinTask.java:1424)
    at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
    at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
    at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
    at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:transformDexArchiveWithDexMergerForArm64Debug'.
> com.android.build.api.transform.TransformException: com.android.dex.DexException: Multiple dex files define Landroid/support/v13/view/inputmethod/InputContentInfoCompat$InputContentInfoCompatImpl;

EDIT: btw. i completely reinstalled my android sdks today. so maybe that's an additional helpful hint. These are my current versions:

 build-tools;25.0.3                                                                | 25.0.3  | Android SDK Build-Tools 25.0.3                  | build-tools/25.0.3/
  build-tools;26.0.3                                                                | 26.0.3  | Android SDK Build-Tools 26.0.3                  | build-tools/26.0.3/
  build-tools;27.0.2                                                                | 27.0.2  | Android SDK Build-Tools 27.0.2                  | build-tools/27.0.2/
  build-tools;27.0.3                                                                | 27.0.3  | Android SDK Build-Tools 27.0.3                  | build-tools/27.0.3/
  emulator                                                                          | 26.1.4  | Android Emulator                                | emulator/
  extras;android;m2repository                                                       | 47.0.0  | Android Support Repository                      | extras/android/m2repository/
  extras;google;m2repository                                                        | 58      | Google Repository                               | extras/google/m2repository/
  extras;intel;Hardware_Accelerated_Execution_Manager                               | 6.2.1   | Intel x86 Emulator Accelerator (HAXM installer) | extras/intel/Hardware_Accelerated_Execution_Manager/
  extras;m2repository;com;android;support;constraint;constraint-layout-solver;1.0.2 | 1       | Solver for ConstraintLayout 1.0.2               | extras/m2repository/com/android/support/constraint/constraint-layout-solver/1.0.2/
  extras;m2repository;com;android;support;constraint;constraint-layout;1.0.2        | 1       | ConstraintLayout for Android 1.0.2              | extras/m2repository/com/android/support/constraint/constraint-layout/1.0.2/
  patcher;v4                                                                        | 1       | SDK Patch Applier v4                            | patcher/v4/
  platform-tools                                                                    | 27.0.1  | Android SDK Platform-Tools                      | platform-tools/
  platforms;android-25                                                              | 3       | Android SDK Platform 25                         | platforms/android-25/
  platforms;android-26                                                              | 2       | Android SDK Platform 26                         | platforms/android-26/
  platforms;android-27                                                              | 1       | Android SDK Platform 27                         | platforms/android-27/
  sources;android-25                                                                | 1       | Sources for Android 25                          | sources/android-25/
  sources;android-26                                                                | 1       | Sources for Android 26                          | sources/android-26/
  tools                                                                             | 26.1.1  | Android SDK Tools                               | tools/
macdonst commented 6 years ago

@flipace thanks, that is some actionable information. I've been able to reproduce the error with the push + camera or push + barcode. Both are using support-v4.

Quick work around for folks, try this:

cordova platform rm android
cordova platform add android

and let me know if that works.

flipace commented 6 years ago

@macdonst when i just use add android it adds android@~6.3.0 and i receive this error:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':transformClassesWithJarMergingForArmv7Debug'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: android/support/v13/view/DragAndDropPermissionsCompat.class

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 21.098 secs
Error: /Users/patrickneschkudla/Development/bitbucket.org_ovos/ecosystem/app-ovos-play-micro/cordova/platforms/android/gradlew: Command failed with exit code 1 Error output:
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':transformClassesWithJarMergingForArmv7Debug'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: android/support/v13/view/DragAndDropPermissionsCompat.class

With android@7.1.0 i get the error with multiple dex files define... i posted above :/

bhandaribhumin commented 6 years ago

@macdonst Already try

cordova platform rm android
cordova platform add android

but it still same error

vshl commented 6 years ago

@macdonst : Our project has local-notifications, barcodescanner, camera plugins that use the support library v4.

I followed the steps below several times to encounter the same issue:

cordova platform rm android
cordova platform add android

The workaround I mentioned in my earlier reply works for now.

bhandaribhumin commented 6 years ago

@flipace please let me know..!

flipace commented 6 years ago

okay, so i can confirm that in our case it seems to have something to do with crosswalk. it doesn't matter however whether i set the MULTIPLEAPK setting to false. will dig a bit deeper...

vshl commented 6 years ago

@macdonst , I can confirm that the project builds properly when I remove the phonegap-plugin-barcodescanner plugin (that uses Android support v4). Adding back the plugin resurfaces the same issue as this thread. What can be done in situations like this?

junelau commented 6 years ago

@vshl's fix worked for me.

cordova plugin version

cordova-plugin-camera 4.0.2 "Camera"
cordova-plugin-crosswalk-webview 2.4.0 "Crosswalk WebView Engine"
cordova-plugin-device 2.0.1 "Device"
cordova-plugin-facebook4 1.9.1 "Facebook Connect"
cordova-plugin-file 6.0.1 "File"
cordova-plugin-inappbrowser 2.0.2 "InAppBrowser"
cordova-plugin-splashscreen 5.0.2 "Splashscreen"
cordova-plugin-whitelist 1.3.3 "Whitelist"
phonegap-plugin-push 2.1.3 "PushPlugin"

Building an ionic v1 project:

ionic info

    @ionic/cli-utils  : 1.19.1
    ionic (Ionic CLI) : 3.19.1

global packages:

    cordova (Cordova CLI) : 8.0.0

local packages:

    Cordova Platforms : android 6.3.0
    Ionic Framework   : ionic1 1.2.1

System:

    Android SDK Tools : 26.1.1
    ios-deploy        : 1.9.2
    Node              : v9.3.0
    npm               : 5.6.0
    OS                : macOS High Sierra
    Xcode             : Xcode 9.2 Build version 9C40b
mororc commented 6 years ago

Reinstall project Reinstall all plugins Error occurs after installation plugin phonegap-plugin-push. Edit file platforms/android/build.gradle:

configurations {
    all*.exclude group: 'com.android.support', module: 'support-v13'
}

The application runs without errors

My plugins list: com.napolitano.cordova.plugin.intent 0.1.3 "IntentPlugin" cordova-plugin-actionsheet 2.3.3 "ActionSheet" cordova-plugin-app-event 1.2.1 "Application Events" cordova-plugin-appminimize 1.0 "AppMinimize" cordova-plugin-calendar 5.0.0 "Calendar" cordova-plugin-camera 4.0.2 "Camera" cordova-plugin-console 1.1.0 "Console" cordova-plugin-crop-mod 1.0.0 "CropPlugin" cordova-plugin-crosswalk-webview 2.4.0 "Crosswalk WebView Engine" cordova-plugin-cszbar 1.3.2 "ZBar barcode scanner" cordova-plugin-device 2.0.1 "Device" cordova-plugin-dialogs 2.0.1 "Notification" cordova-plugin-file 6.0.1 "File" cordova-plugin-file-transfer 1.7.1 "File Transfer" cordova-plugin-geolocation 4.0.1 "Geolocation" cordova-plugin-http 1.2.0 "SSL Pinning" cordova-plugin-image-picker 1.1.1 "ImagePicker" cordova-plugin-inappbrowser 2.0.2 "InAppBrowser" cordova-plugin-media 5.0.2 "Media" cordova-plugin-media-capture 3.0.1 "Capture" cordova-plugin-network-information 2.0.1 "Network Information" cordova-plugin-splashscreen 5.0.2 "Splashscreen" cordova-plugin-statusbar 2.4.1 "StatusBar" cordova-plugin-vibration 3.0.1 "Vibration" cordova-plugin-whitelist 1.3.3 "Whitelist" cordova-plugin-x-socialsharing 5.3.1 "SocialSharing" cordova.plugins.diagnostic 3.9.2 "Diagnostic" de.appplant.cordova.plugin.local-notification 0.8.5 "LocalNotification" es6-promise-plugin 4.1.0 "Promise" phonegap-plugin-push 2.1.3 "PushPlugin"

valentinchevalier commented 6 years ago

I encounter the same issue.

When I build the project without phonegap-plugin-push everything is fine. But when I add it, the Multiple dex files define Landroid/support/v13/view/inputmethod/EditorInfoCompat; error occurs.

Adding

configurations {
    all*.exclude group: 'com.android.support', module: 'support-v13'
}

into platforms/android/build.gradle doesn't fix the error for me.

ionic info

cli packages: (C:\Users\dev3\AppData\Roaming\nvm\v8.9.1\node_modules)
    @ionic/cli-utils  : 1.19.1
    ionic (Ionic CLI) : 3.19.1

global packages:
    cordova (Cordova CLI) : 8.0.0

local packages:
    @ionic/app-scripts : 3.1.6
    Cordova Platforms  : android 7.0.0
    Ionic Framework    : ionic-angular 3.9.2

System:
    Android SDK Tools : 26.1.1
    Node              : v8.9.1
    npm               : 5.5.1
    OS                : Windows 10
bhumin3i commented 6 years ago

configurations { all*.exclude group: 'com.android.support', module: 'support-v13' } adding above not fixing the error for me as well

Ionic info:

cli packages: (C:\Users\1000227\AppData\Roaming\npm\node_modules)

@ionic/cli-utils  : 1.19.1
ionic (Ionic CLI) : 3.19.1

global packages:

cordova (Cordova CLI) : 8.0.0

local packages:

@ionic/app-scripts : 3.1.6
Cordova Platforms  : android 7.0.0
Ionic Framework    : ionic-angular 3.9.2

System:

Node : v8.9.2
npm  : 5.6.0
OS   : Windows 7

Environment Variables:

ANDROID_HOME : not set

Misc:

backend : pro

Plugin list cordova-plugin-app-event 1.2.1 "Application Events" cordova-plugin-badge 0.8.7 "Badge" cordova-plugin-device 1.1.4 "Device" cordova-plugin-device-orientation 1.0.7 "Device Orientation" cordova-plugin-geolocation 4.0.1 "Geolocation" cordova-plugin-googlemaps 2.2.5 "cordova-plugin-googlemaps" cordova-plugin-inappbrowser 2.0.2 "InAppBrowser" cordova-plugin-ionic-webview 1.1.16 "cordova-plugin-ionic-webview" cordova-plugin-local-notification 0.9.0-beta.2 "LocalNotification" cordova-plugin-network-information 2.0.1 "Network Information" cordova-plugin-splashscreen 4.0.3 "Splashscreen" cordova-plugin-whitelist 1.3.1 "Whitelist" cordova-sqlite-storage 2.2.0 "Cordova sqlite storage plugin" de.appplant.cordova.plugin.local-notification 0.8.5 "LocalNotification" es6-promise-plugin 4.1.0 "Promise" ionic-plugin-keyboard 2.2.1 "Keyboard" phonegap-plugin-barcodescanner 7.0.2 "BarcodeScanner" phonegap-plugin-push 2.1.3 "PushPlugin" wifiwizard2 2.1.0 "WifiWizard2"

studiostart commented 6 years ago

In my project, I obtain a transformDexArchiveWithDexMergerForDebugDex error if I run with phonegap-plugins-push and phonegap-plugin-barcodescanner installed. When I remove one of them, the project works.

EDIT: in my case, I resolved removing this string: compile 'com.android.support:support-v4:+' from the file: (your_project)-barcodescanner.gradle

shrijeetDeshmukh commented 6 years ago

Removing this line from project properties worked for me, cordova.system.library.3=com.android.support:support-v13:26.+

bhandaribhumin commented 6 years ago

Thanks a lot @shrijeetDeshmukh it's working... you save my life..:)

chauthai commented 6 years ago

As suggested in my pull request you can also manually change the version in the project.properties to com.android.support:support-v13:27.+.

HugoHeneault commented 6 years ago

I lost some time trying to find the right project.properties. 😄

So it's in platforms/android/project.properties that you should remove

cordova.system.library.3=com.android.support:support-v13:26.+

or replace it by

cordova.system.library.3=com.android.support:support-v13:27.+

(but I don't know the difference between the two of them)

andreyliventsev commented 6 years ago

Also actual for me

chauthai commented 6 years ago

I've dugged a little deeper into the issue. As you can see in the table below I use 4 Cordova plugins with different versions of the Android Support Library. v4 or v13 is not important in this case.

Plugin Plugin Version Android Support Library Version of Android Support Library
cordova-plugin-camera ^2.4.1 com.android.support:support-v4 24.1.1+
cordova-plugin-file-opener2 git-hash 4f4f33 com.android.support:support-v4 +
phonegap-plugin-barcodescanner ^6.0.8 com.android.support:support-v4 +
phonegap-plugin-push 2.1.3 com.android.support:support-v17 26.+

The build error resulted from the release of a new Android Support Version at the end of February. The barcode scanner and file-opener2 plugin would download the latest 27.1.0 version of the support library due to the wildcard +. The new version is apparently incompatible to the 26.+ version of the push plugin. This explains the sudden failure of working builds.

We've discussed this in our team and the only way to really avoid the problem in the future, is to set up our own maven mirror, where we control the version of the Android Support Library. Or to fork all Cordova plugins in use, which is not viable.

macdonst commented 6 years ago

Currently fixed in master. Big thanks to @chauthai for the info and the PR. I've setup a preference in plugin.xml so that you will be able to set what version of the support library you are using in your app. I'll update the phonegap-plugin-barcodescanner & cordova-plugin-camera myself and possibly send a PR to cordova-plugin-file-opener2.

pliablepixels commented 6 years ago

@macdonst will this fix be propagated to a push plugin version that is compatible with cordova-android 6.3.0? I am using an ionic v1 project which doesn't seem to be compatible with cordova-android 7.x and your 2.2.x versions need 7.x. I don't want to directly modify platform/plugins as that gets overwritten

nprail commented 6 years ago

@macdonst Same as @pliablepixels. I can't upgrade to 2.2.x because I can't use cordova-android 7.x.

@pliablepixels If this fix is not published to 2.1.x, you can use this workaround:

Create a build-extras.gradle file in your projects root directory with this contents:

configurations.all {
    resolutionStrategy {
        force 'com.android.support:support-v4:27.1.0'
        force 'com.android.support:support-v13:27.1.0'
    }
}
Original See here. ```gradle configurations { all*.exclude group: 'com.android.support', module: 'support-v13' } ```

Then add this to your config.xml inside of <platform name="android">

<resource-file src="build-extras.gradle" target="build-extras.gradle" />
<framework custom="true" src="build-extras.gradle" type="gradleReference" />

That should fix the build.

PSTime commented 6 years ago

Have same issue. Thank you @nprail , but it was not helpful

PSTime commented 6 years ago

Have in phonegap-plugin-push 2.2.1 compile 'com.android.support:support-v4:+' in phonegap-plugin-barcodescanner 7.0.2 "BarcodeScanner" in cordova-plugin-camera 4.0.2 "Camera"

does anyone have solution for it ? cordova-android@7.1.0

pliablepixels commented 6 years ago

It's such a bleeding pain in the posterior building stuff reliably. Nothing to do with @macdonst 's fine library, but the build process in general. You don't change a thing and yet your project stops compiling because some darn support library changed remotely on the internet. I wish there was a way to 100% freeze a full build process along with versions (and if there is, I'd love someone to point me to a way that doesn't involve mirroring the entire google library repo)

Anyway, @nprail thanks - unfortunately, as @PSTime says, adding it to config.xml this way doesn't work (at least for me). I read the official cordova docs and it looks like I need to put build-extras.gradle inside platforms/android. So I wrote an ionic hook to copy the gradle file over before build.

It now compiles my binary both native and crosswalk modes.

This is my hook in hooks/before_prepare/01_pp_hacks.sh --> note that this ideally should be a nodeJS file - I wrote a shell script a long time ago, but should really convert it.

echo "Copying gradle hack for push-plugin-2.1.3"
echo "-------------------------------------------"

if [ -d "platforms/android" ]; then
        exe cp www/external/build-extras.gradle platforms/android
else
        echo "Directory platforms/android does not exist, skipping..."
fi

So I'm just copying the build-extras.gradle to the right directory as part of the build tooling

Where build-extras.gradle is exactly what was written above

configurations {
    all*.exclude group: 'com.android.support', module: 'support-v13'
}
nprail commented 6 years ago

@pliablepixels @PSTime Oh, sorry, I forgot to mention the hook part. You can also use <resource-file src="build-extras.gradle" target="build-extras.gradle" /> instead of a hook.

I have the same frustrations. I'd be nice for a way to just lock all versions. But that is an entirely different conversation.

chauthai commented 6 years ago

A colleague just discovered that a new alpha version of the Android Support Library was released. It breaks his local build. A similar error can be found at Stackoverflow. So I think a best practice for Cordova plugins is to abandon the + forever and pin at least the major version, e.g. 27.+.

flipace commented 6 years ago

@PSTime for me - the workaround @nprail posted did also not work.

I had another issue now however which was related to crosswalk it seems.

I was able to fix it by using this configuration in build-extras.gradle with the same config as @nprail posted:

In config.xml android platform:

<resource-file src="build-extras.gradle" target="build-extras.gradle" />
configurations.all {
    resolutionStrategy {
    force 'com.android.support:support-v4:27.1.0'
    }
}

@chauthai maybe this would also be a viable solution for you?

chauthai commented 6 years ago

@flipace Thanks a lot for the solution! It solved the problem with the alpha version of the Android Support Library.

nprail commented 6 years ago

@flipace's solution seems to work better than mine. Although, I added to it by forcing both support-v4 and support-v13 to 27.1.0.

I updated my original comment to reflect that.

pliablepixels commented 6 years ago

Yes indeed. What worked yesterday stopped working today 🙄 due to yet another google library update. I had to combine both the tips above

What worked for me:

  1. Add <resource-file src="build-extras.gradle" target="build-extras.gradle" /> to config.xml under <platform name="android">

  2. Add both the configs to build-extras.gradle in my project root. I suppose we can combine both, but it works...

configurations.all {
    resolutionStrategy {
        force 'com.android.support:support-v4:27.1.0'
    }
}
configurations {
    all*.exclude group: 'com.android.support', module: 'support-v13'
}

I removed the hook. Thanks @flipace and @nprail

ihsanberahim commented 6 years ago

Thank you @pliablepixels. You solution is correct. Just a little bit different on cordova-android 7.

So,

<resource-file src="build-extras.gradle" target="build-extras.gradle" />

for cordova-android 7 should be like this

<resource-file src="build-extras.gradle" target="app/build-extras.gradle" />

i found this from stackoverflow

lock[bot] commented 6 years ago

This thread has been automatically locked.