phonegap / phonegap-plugin-barcodescanner

cross-platform BarcodeScanner for Cordova / PhoneGap
MIT License
1.27k stars 1.41k forks source link

Android studio compiling problem in Ionic 3 project #835

Closed jtmuti closed 4 years ago

jtmuti commented 5 years ago

This is related to a big app that has developed since 2017. That is why I have not started to migrate all code to Ionic 4. That can also effect on this problem. I have generated the feature in Ionic devapp and it worked ok.

Gradle sync is working successfully but building does next Android studio error:

Duplicate class barcodescanner.xservices.nl.barcodescanner.BuildConfig found in modules jetified-barcodescanner-release-2.1.5-runtime.jar (:barcodescanner-release-2.1.5:) and jetified-barcodescanner-release-2.1.5-runtime.jar (barcodescanner-release-2.1.5.aar)
Duplicate class com.google.zxing.BarcodeFormat found in modules jetified-barcodescanner-release-2.1.5-runtime.jar (:barcodescanner-release-2.1.5:) and jetified-barcodescanner-release-2.1.5-runtime.jar (barcodescanner-release-2.1.5.aar)
Duplicate class com.google.zxing.Binarizer found in modules jetified-barcodescanner-release-2.1.5-runtime.jar (:barcodescanner-release-2.1.5:) and jetified-barcodescanner-release-2.1.5-runtime.jar (barcodescanner-release-2.1.5.aar)

Few hundred of these errors...

This is related to dependency resolution errors. I have not been able solve this problem. I tried to remove plugins that have used zxing -classes but the error still remained. I think the problem is related something inside the plugin.

config.xml <plugin name="phonegap-plugin-barcodescanner" spec="~8.1.0" /> packege.json "@ionic-native/barcode-scanner": "^4.20.0",

ionic info

Ionic:

   ionic (Ionic CLI)  : 4.12.0
   Ionic Framework    : ionic-angular 3.9.2
   @ionic/app-scripts : 3.2.3

Cordova:

   cordova (Cordova CLI) : 8.1.2 (cordova-lib@8.1.1)
   Cordova Platforms     : android 7.1.4
   Cordova Plugins       : cordova-plugin-ionic-webview 1.2.1, (and 20 other plugins)

System:

   Android SDK Tools : 26.1.1 (C:\Users\OMISTAJA\AppData\Local\Android\Sdk)
   NodeJS            : v10.15.1 (C:\Program Files\nodejs\node.exe)
   npm               : 6.11.3
   OS                : Windows 10

Build Gradle is: 5.4.1 Android Studio is 3.5.2 and using AndroidX

jtmuti commented 4 years ago

The solution was too easy. Somehow the plug in generate bug to the \phonegap-plugin-barcodescanner/Xhampions-barcodescanner.gradle

dependencies {
    //compile(name:'barcodescanner-release-2.1.5', ext:'aar')
}

This dependencie is making the duplicate class error. Comment it like above.

lock[bot] commented 4 years ago

This thread has been automatically locked.