[MOD-2590] Android: Modules "ti.barcode" and "facebook" conflict as of 9.0.0
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Critical |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2020-04-22T17:31:41.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | Barcode |
Labels | android, facebook, gradle, module, ti.barcode |
Reporter | Srinivasan Pulipakkam |
Assignee | Joshua Quick |
Created | 2020-03-30T19:26:52.000+0000 |
Updated | 2020-04-22T17:31:41.000+0000 |
Description
*Summary:*
An Android app build will fail if it include the following modules at the same time...
* ti.barcode (v5.0.0)
* facebook (v9.0.0)
*Steps to reproduce:*
Create a new project targeting Titanium 9.0.0.
Set up the "tiapp.xml" with the below modules.
Build for Android.
<ti:app>
<modules>
<module platform="android">facebook</module>
<module platform="android">ti.barcode</module>
</modules>
</ti:app>
*Result:*
You'll get several build error regarding duplicate Java classes under the "com.google.zxing" package.
[ERROR] : [GRADLE] java.lang.RuntimeException: Duplicate class com.google.zxing.BarcodeFormat found in modules core-3.3.3.jar (com.google.zxing:core:3.3.3) and core-3.3.3.jar (ti:barcode:5.0.0)
[ERROR] : [GRADLE] Duplicate class com.google.zxing.Binarizer found in modules core-3.3.3.jar (com.google.zxing:core:3.3.3) and core-3.3.3.jar (ti:barcode:5.0.0)
[ERROR] : [GRADLE] Duplicate class com.google.zxing.BinaryBitmap found in modules core-3.3.3.jar (com.google.zxing:core:3.3.3) and core-3.3.3.jar (ti:barcode:5.0.0)
[ERROR] : [GRADLE] Duplicate class com.google.zxing.ChecksumException found in modules core-3.3.3.jar (com.google.zxing:core:3.3.3) and core-3.3.3.jar (ti:barcode:5.0.0)
[ERROR] : [GRADLE] Duplicate class com.google.zxing.DecodeHintType found in modules core-3.3.3.jar (com.google.zxing:core:3.3.3) and core-3.3.3.jar (ti:barcode:5.0.0)
[ERROR] : [GRADLE] Duplicate class com.google.zxing.Dimension found in modules core-3.3.3.jar (com.google.zxing:core:3.3.3) and core-3.3.3.jar (ti:barcode:5.0.0)
*Cause:*
When we migrated the "facebook" module to gradle for Titanium 9.0.0, it ended up including the same zxing core library that our "ti.barcode" module uses which caused the above class name conflict.
[facebook-common/build.gradle#L39](https://github.com/facebook/facebook-android-sdk/blob/ca9ba9cee5ababe944619aee76884708acc6b482/facebook-common/build.gradle#L39)
*Solution:*
Update the "ti.barcode" module's "build.gradle" file to use the below dependencies and delete it's "lib" folder of JARs. This way gradle/maven's dependency management can resolve this for us.
dependencies {
implementation 'com.google.zxing:core:3.4.0'
implementation 'com.google.zxing:android-core:3.3.0'
implementation 'com.google.zxing:android-integration:3.3.0'
}
*Work-Around:*
Add file ./platform/android/build.gradle
under your project with below contents.
_(Note that this work-around will need to be removed when we fix the "ti.barcode" module or else a runtime error will occur.)_
configurations {
implementation {
// Work-around which excludes ZXing JARs until "ti.barcode" module has been updated to v5.0.1.
// You'll need to remove this once you upgrade to "ti.barcode" 5.0.1 or else runtime errors will occur.
exclude group: 'com.google.zxing', module: '*'
}
}
PR: https://github.com/appcelerator-modules/ti.barcode/pull/126
FR Passed. PR Merged.
Verified the fix with module 5.0.1. Closing.