添加phonegap-plugin-barcodescanner后无法构建Cordova Android Projet

时间:2018-10-18 06:29:46

标签: android cordova gradle

当我尝试构建android cordova项目时收到异常消息。删除插件后,编译工作正常,当我再次添加该插件时,它会失败,并显示相同的错误。

欢迎任何帮助,

谢谢 编译项目失败并出现错误

mbopat-2:$ cordova构建android

ANDROID_HOME=/Users/patrick/Library/Android/sdk
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_152.jdk/Contents/Home
Subproject Path: CordovaLib
Configuration 'compile' in project ':' is deprecated. Use 'implementation' instead.
The Task.leftShift(Closure) method has been deprecated and is scheduled to be removed in Gradle 5.0. Please use Task.doLast(Action) instead.
    at 

build_9h46slmadmegn4opsdieo7cxy.run(/Users/patrick/Desktop/VMSharedFolder/Projects/ALMAMobile/platforms/android/build.gradle:147)
registerResGeneratingTask is deprecated, use registerGeneratedFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedFolders(FileCollection)
publishNonDefault is deprecated and has no effect anymore. All variants are now published.
:preBuild UP-TO-DATE
:CordovaLib:preBuild UP-TO-DATE
:CordovaLib:preDebugBuild UP-TO-DATE
:CordovaLib:checkDebugManifest UP-TO-DATE
:CordovaLib:processDebugManifest UP-TO-DATE
:preDebugBuild
Warning: The app gradle file must have a dependency on com.google.firebase:firebase-core for Firebase services to work as intended.
Warning: The app gradle file must have a dependency on com.google.firebase:firebase-core for Firebase services to work as intended.
:preDebugBuild UP-TO-DATE
:CordovaLib:compileDebugAidl UP-TO-DATE
:compileDebugAidl UP-TO-DATE
:CordovaLib:packageDebugRenderscript NO-SOURCE
:compileDebugRenderscript UP-TO-DATE
:checkDebugManifest UP-TO-DATE
:generateDebugBuildConfig UP-TO-DATE
:prepareLintJar UP-TO-DATE
:generateDebugResValues
:generateDebugResources
:processDebugGoogleServices
Parsing json file: /Users/patrick/Desktop/VMSharedFolder/Projects/ALMAMobile/platforms/android/google-services.json
:CordovaLib:compileDebugRenderscript UP-TO-DATE
:CordovaLib:generateDebugResValues UP-TO-DATE
:CordovaLib:generateDebugResources UP-TO-DATE
:CordovaLib:packageDebugResources UP-TO-DATE
:mergeDebugResources
:createDebugCompatibleScreenManifests UP-TO-DATE
:processDebugManifest UP-TO-DATE
:splitsDiscoveryTaskDebug UP-TO-DATE
:CordovaLib:platformAttrExtractor UP-TO-DATE
:CordovaLib:processDebugResources UP-TO-DATE
:processDebugResources
:generateDebugSources
:CordovaLib:generateDebugBuildConfig UP-TO-DATE
:CordovaLib:prepareLintJar UP-TO-DATE
:CordovaLib:generateDebugSources UP-TO-DATE
:CordovaLib:javaPreCompileDebug UP-TO-DATE
:CordovaLib:compileDebugJavaWithJavac UP-TO-DATE
:CordovaLib:processDebugJavaRes NO-SOURCE
:CordovaLib:transformClassesAndResourcesWithPrepareIntermediateJarsForDebug UP-TO-DATE
:javaPreCompileDebug UP-TO-DATE
:compileDebugJavaWithJavac UP-TO-DATE
:compileDebugNdk NO-SOURCE
:compileDebugSources UP-TO-DATE
:mergeDebugShaders UP-TO-DATE
:compileDebugShaders UP-TO-DATE
:generateDebugAssets UP-TO-DATE
:CordovaLib:mergeDebugShaders UP-TO-DATE
:CordovaLib:compileDebugShaders UP-TO-DATE
:CordovaLib:generateDebugAssets UP-TO-DATE
:CordovaLib:mergeDebugAssets UP-TO-DATE
:mergeDebugAssets UP-TO-DATE
:transformClassesWithDexBuilderForDebug UP-TO-DATE
:transformClassesWithMultidexlistForDebug UP-TO-DATE
:transformDexArchiveWithDexMergerForDebugDex: Error converting bytecode to dex:
Cause: com.android.dex.DexException: Multiple dex files define Landroid/support/v13/view/DragStartHelper;
    UNEXPECTED TOP-LEVEL EXCEPTION:
    com.android.dex.DexException: Multiple dex files define Landroid/support/v13/view/DragStartHelper;

com.android.dex.DexException: Multiple dex files define Landroid/support/v13/view/DragStartHelper;
    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.

Cordova CLI版本和cordova平台版本 科尔多瓦8.1.2 科尔多瓦Android 6.4.0

code-push 2.0.6 "CodePushAcquisition"
cordova-plugin-camera 4.0.3 "Camera"
cordova-plugin-code-push 1.11.13 "CodePush"
cordova-plugin-device 2.0.2 "Device"
cordova-plugin-device-motion 2.0.1 "Device Motion"
cordova-plugin-device-orientation 2.0.1 "Device Orientation"
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-globalization 1.11.0 "Globalization"
cordova-plugin-insomnia 4.3.0 "Insomnia (prevent screen sleep)"
cordova-plugin-ionic-keyboard 2.1.3 "cordova-plugin-ionic-keyboard"
cordova-plugin-mauron85-background-geolocation 2.3.6 "CDVBackgroundGeolocation"
cordova-plugin-media 5.0.2 "Media"
cordova-plugin-media-capture 3.0.2 "Capture"
cordova-plugin-network-information 2.0.1 "Network Information"
cordova-plugin-splashscreen 5.0.2 "Splashscreen"
cordova-plugin-statusbar 2.4.2 "StatusBar"
cordova-plugin-vibration 3.1.0 "Vibration"
cordova-plugin-whitelist 1.3.3 "Whitelist"
cordova-plugin-x-toast 2.7.0 "Toast"
cordova-plugin-zip 3.1.0 "cordova-plugin-zip"
cordova-support-google-services 1.2.1 "cordova-support-google-services"
phonegap-plugin-barcodescanner 8.0.0 "BarcodeScanner"
phonegap-plugin-multidex 1.0.0 "Multidex"
phonegap-plugin-push 2.1.2 "PushPlugin"

1 个答案:

答案 0 :(得分:0)

您的问题是您项目中的不同插件(例如phonegap-plugin-barcodescannerphonegap-plugin-pushcordova-plugin-background-geolocation)指定了不同版本的Android支持库,从而在Gradle解决时引起冲突Android构建过程中的依赖项。

您可以使用cordova-android-support-gradle-release插件覆盖它们指定的版本,并与应解决构建故障的单个版本对齐,例如:

cordova plugin add cordova-android-support-gradle-release --variable ANDROID_SUPPORT_VERSION=27.+