无法使用cordova-plugin-facebook4和phonegap-plugin-barcodescanner构建Cordova应用

时间:2018-09-11 07:17:42

标签: android cordova cordova-plugins phonegap-plugins

同时使用cordova-plugin-facebook@2.4.0和phonegap-plugin-barcodescanner@8.0.0时,构建我的cordova应用程序时出现问题。

  • cordova-cli@8.0.0
  • cordova-android@7.1.1
  • cordova-plugin-facebook@2.4.0
  • phonegap-plugin-barcodescanner@8.0.0
  • 未使用其他插件
  • 使用cordova-plugin-facebook@1.7.4时没有问题
  • 还尝试使用cordova-android-support-gradle-release失败

config.xml

<platform name="android">
    <hook src="hooks/__myapp/android_plugins_plugman.js" type="after_platform_add" />
    <preference name="android-minSdkVersion" value="19" />
    <preference name="android-targetSdkVersion" value="26" />
    <preference name="AndroidPersistentFileLocation" value="Internal" />
    <icon density="ldpi" src="resources/android/icon/drawable-ldpi-icon.png" />
    ...
    <splash density="land-ldpi" src="resources/android/splash/drawable-land-ldpi-screen.png" />
    ...
    <config-file parent="/resources" target="./res/values/strings.xml">
        <string name="fb_app_id">some app id</string>
        <string name="fb_app_name">app name</string>
    </config-file>
</platform>
...
<plugin name="cordova-plugin-facebook4" spec="file:cordova_plugins/cordova-plugin-facebook4-2.4.0">
    <variable name="APP_ID" value="some app id" />
    <variable name="APP_NAME" value="app name" />
    <variable name="ANDROID_SDK_VERSION" value="4.+" />
</plugin>
<plugin name="phonegap-plugin-barcodescanner" spec="file:cordova_plugins/phonegap-plugin-barcodescanner-8.0.0">
    <variable name="CAMERA_USAGE_DESCRIPTION" value="some description" />
    <variable name="ANDROID_SUPPORT_V4_VERSION" value="27.1.1" />
</plugin>
...
<engine name="ios" spec="^4.5.5" />
<engine name="android" spec="^7.0.2" />

错误日志

Android Studio project detected


config file res/values/facebookconnect.xml requested for changes not found at /Users/SOME_USER_NAME/projects/SOME_PROJECT/platforms/android/res/values/facebookconnect.xml, ignoring

config file res/values/facebookconnect.xml requested for changes not found at /Users/SOME_USER_NAME/projects/SOME_PROJECT/platforms/android/res/values/facebookconnect.xml, ignoring


Running command: /Users/SOME_USER_NAME/projects/SOME_PROJECT/hooks/after_prepare/010_add_platform_class.js /Users/SOME_USER_NAME/projects/SOME_PROJECT


Running command: /Users/SOME_USER_NAME/projects/SOME_PROJECT/hooks/after_prepare/020_remove_sass_from_platforms.js /Users/SOME_USER_NAME/projects/SOME_PROJECT


ANDROID_HOME=/Users/SOME_USER_NAME/Library/Android/sdk

JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home

studio

:wrapper




BUILD SUCCESSFUL




Total time: 2.882 secs




This build could be faster, please consider using the Gradle Daemon: https://docs.gradle.org/2.14/userguide/gradle_daemon.html


Subproject Path: CordovaLib


Subproject Path: app


publishNonDefault is deprecated and has no effect anymore. All variants are now published.


Configuration 'compile' in project ':app' 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_3woh5i5cs7vu80u1tavsoqgsd.run(/Users/SOME_USER_NAME/projects/SOME_PROJECT/platforms/android/app/build.gradle:144)


:CordovaLib:preBuild
 UP-TO-DATE


:CordovaLib:preDebugBuild
 UP-TO-DATE


:CordovaLib:compileDebugAidl


:CordovaLib:compileDebugRenderscript


:CordovaLib:checkDebugManifest


:CordovaLib:generateDebugBuildConfig


:CordovaLib:prepareLintJar


:CordovaLib:generateDebugResValues


:CordovaLib:generateDebugResources


:CordovaLib:packageDebugResources


:CordovaLib:platformAttrExtractor


:CordovaLib:processDebugManifest


:CordovaLib:javaPreCompileDebug


:CordovaLib:processDebugJavaRes

NO-SOURCE

:app:preBuild

UP-TO-DATE

:app:preDebugBuild


Download https://maven.google.com/com/android/support/appcompat-v7/27.0.2/appcompat-v7-27.0.2.pom


Download https://maven.google.com/com/android/support/customtabs/27.0.2/customtabs-27.0.2.pom


Download https://maven.google.com/com/android/support/cardview-v7/27.0.2/cardview-v7-27.0.2.pom


Download https://maven.google.com/com/android/support/animated-vector-drawable/27.0.2/animated-vector-drawable-27.0.2.pom

Download https://maven.google.com/com/android/support/support-vector-drawable/27.0.2/support-vector-drawable-27.0.2.pom

Download https://maven.google.com/com/android/support/customtabs/27.0.2/customtabs-27.0.2.aar

Download https://maven.google.com/com/android/support/animated-vector-drawable/27.0.2/animated-vector-drawable-27.0.2.aar


Download https://maven.google.com/com/android/support/support-vector-drawable/27.0.2/support-vector-drawable-27.0.2.aar


Download https://maven.google.com/com/android/support/appcompat-v7/27.0.2/appcompat-v7-27.0.2.aar


Download https://maven.google.com/com/android/support/cardview-v7/27.0.2/cardview-v7-27.0.2.aar


:app:compileDebugAidl


:CordovaLib:packageDebugRenderscript

NO-SOURCE

:app:compileDebugRenderscript


:app:checkDebugManifest


:app:generateDebugBuildConfig


:app:prepareLintJar


:app:generateDebugResValues


:app:generateDebugResources


:app:mergeDebugResources


:app:createDebugCompatibleScreenManifests


:CordovaLib:processDebugResources


:CordovaLib:generateDebugSources


:CordovaLib:compileDebugJavaWithJavac
Note: Some input files use or override a deprecated API.

Note: Recompile with -Xlint:deprecation for details.




:CordovaLib:transformClassesAndResourcesWithPrepareIntermediateJarsForDebug


:app:processDebugManifest


:app:splitsDiscoveryTaskDebug


:app:processDebugResources


:app:generateDebugSources


:app:javaPreCompileDebug


:app:compileDebugJavaWithJavac
Note: /Users/SOME_USER_NAME/projects/SOME_PROJECT/platforms/android/app/src/main/java/org/apache/cordova/facebook/ConnectPlugin.java uses or overrides a deprecated API.


Note: Recompile with -Xlint:deprecation for details.




:app:compileDebugNdk
 NO-SOURCE

:app:compileDebugSources


:CordovaLib:mergeDebugShaders


:CordovaLib:compileDebugShaders


:CordovaLib:generateDebugAssets


:CordovaLib:mergeDebugAssets


:app:mergeDebugShaders


:app:compileDebugShaders


:app:generateDebugAssets


:app:mergeDebugAssets


:app:transformClassesWithStackFramesFixerForDebug


:app:transformClassesWithDesugarForDebug


:app:transformClassesWithDexBuilderForDebug


:app:transformDexArchiveWithExternalLibsDexMergerForDebug

FAILED



FAILURE: Build failed with an exception.



* What went wrong:


Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.


>
java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex


* 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 25s

37 actionable tasks: 37 executed


(node:16024) UnhandledPromiseRejectionWarning: Error: /Users/SOME_USER_NAME/projects/SOME_PROJECT/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: /Users/SOME_USER_NAME/projects/SOME_PROJECT/platforms/android/app/src/main/java/org/apache/cordova/facebook/ConnectPlugin.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex

* 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 25s
    at ChildProcess.whenDone (/Users/SOME_USER_NAME/projects/SOME_PROJECT/platforms/android/cordova/node_modules/cordova-common/src/superspawn.js:169:23)
    at ChildProcess.emit (events.js:182:13)
    at maybeClose (internal/child_process.js:962:16)
    at Socket.stream.socket.on (internal/child_process.js:381:11)
    at Socket.emit (events.js:182:13)
    at Pipe._handle.close (net.js:606:12)

(node:16024) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)

(node:16024) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

讨论从https://github.com/jeduan/cordova-plugin-facebook4/issues/705开始。也许有人在这里有更多的想法。 谢谢!

1 个答案:

答案 0 :(得分:0)

尝试使用此插件

<plugin spec="https://github.com/Telerik-Verified-Plugins/BarcodeScanner.git" source="git" > </plugin>