【问题标题】:can´t create an apk with an ionic project无法使用离子项目创建 apk
【发布时间】:2017-07-14 20:26:07
【问题描述】:

嗨,我是 ionic 的新手,我试图创建一个 apk 来测试我的 qr 扫描仪项目,但是当我运行命令 ionic cordova build android --release 我得到以下错误输出:

有关清单合并的更多信息,请参阅http://g.co/androidstudio/manifest-merger

    :processReleaseManifest FAILED

    BUILD FAILED

    Total time: 13.446 secs
    C:\Users\delacrga\Ionic projects\myApp\platforms\android\AndroidManifest.xml:19:5-65 Error:
    Element uses-permission#android.permission.CAMERA at AndroidManifest.xml:19:5-65 duplicated with element
    declared at AndroidManifest.xml:16:5-90
    C:\Users\delacrga\Ionic projects\myApp\platforms\android\AndroidManifest.xml:21:5-84 Error:
    Element uses-feature#android.hardware.camera at AndroidManifest.xml:21:5-84 duplicated with element declared at
    AndroidManifest.xml:17:5-85
    C:\Users\delacrga\Ionic projects\myApp\platforms\android\AndroidManifest.xml Error:
    Validation failed, exiting

    FAILURE: Build failed with an exception.

    * What went wrong:
    Execution failed for task ':processReleaseManifest'.
    > Manifest merger failed with multiple errors, see logs

    * Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
    Error: cmd: Command failed with exit code 1 Error output:
    C:\Users\delacrga\Ionic projects\myApp\platforms\android\AndroidManifest.xml:19:5-65 Error:
    Element uses-permission#android.permission.CAMERA at AndroidManifest.xml:19:5-65 duplicated with element
    declared at AndroidManifest.xml:16:5-90
    C:\Users\delacrga\Ionic projects\myApp\platforms\android\AndroidManifest.xml:21:5-84 Error:
    Element uses-feature#android.hardware.camera at AndroidManifest.xml:21:5-84 duplicated with element declared at
    AndroidManifest.xml:17:5-85
    C:\Users\delacrga\Ionic projects\myApp\platforms\android\AndroidManifest.xml Error:
    Validation failed, exiting

    FAILURE: Build failed with an exception.

    * What went wrong:
    Execution failed for task ':processReleaseManifest'.
    > Manifest merger failed with multiple errors, see logs

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

有人可以帮我解决这个问题吗?

输出:

C:\Users\delacrga\Ionic projects\myApp>ionic cordova build android --prod --release -- -- --keystore=filename.keystore --alias=myalias
Running app-scripts build: --prod --iscordovaserve --externalIpRequired --nobrowser

[08:52:04]  build prod started ...
[08:52:04]  clean started ...
[08:52:04]  clean finished in 10 ms
[08:52:04]  copy started ...
[08:52:04]  ngc started ...
[08:52:15]  ngc finished in 11.48 s
[08:52:15]  preprocess started ...
[08:52:16]  deeplinks started ...
[08:52:16]  deeplinks finished in 63 ms
[08:52:16]  optimization started ...
[08:52:16]  copy finished in 11.85 s
[08:52:26]  optimization finished in 10.47 s
[08:52:26]  preprocess finished in 10.54 s
[08:52:26]  webpack started ...
[08:52:32]  webpack finished in 5.46 s
[08:52:32]  sass started ...
[08:52:32]  uglifyjs started ...
[08:52:33]  sass finished in 1.22 s
[08:52:33]  cleancss started ...
[08:52:35]  cleancss finished in 1.93 s
[08:52:42]  uglifyjs finished in 10.23 s
[08:52:42]  postprocess started ...
[08:52:42]  postprocess finished in 15 ms
[08:52:42]  lint started ...
[08:52:42]  build prod finished in 37.83 s
> cordova build android --release -- --keystore=filename.keystore --alias=myalias
× Running command - failed!

[ERROR] Cordova encountered an error.
        You may get more insight by running the Cordova command above directly.

[ERROR] An error occurred while running cordova build android --release -- --keystore=filename.keystore --alias=myalias
        (exit code 1):

        ANDROID_HOME=C:\Users\delacrga\AppData\Local\Android\sdk
        JAVA_HOME=C:\Program Files\java\jdk1.8.0_131
        Subproject Path: CordovaLib
        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_amlj4yw9chmdse17z8bfqqws2.run(C:\Users\delacrga\Ionic
        projects\myApp\platforms\android\build.gradle:139)

        FAILURE: Build failed with an exception.

        * Where:
        Build file 'C:\Users\delacrga\Ionic projects\myApp\platforms\android\build.gradle' line: 289

        * What went wrong:
        A problem occurred evaluating root project 'android'.
        > Keystore file does not exist: C:\Users\delacrga\Ionic projects\myApp\platforms\android\..\..\filename.keystore

        * 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: 4.175 secs
        Error: cmd: Command failed with exit code 1 Error output:
        FAILURE: Build failed with an exception.

        * Where:
        Build file 'C:\Users\delacrga\Ionic projects\myApp\platforms\android\build.gradle' line: 289

        * What went wrong:
        A problem occurred evaluating root project 'android'.
        > Keystore file does not exist: C:\Users\delacrga\Ionic projects\myApp\platforms\android\..\..\filename.keystore

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

【问题讨论】:

    标签: android ionic-framework apk


    【解决方案1】:

    如果您安装了两个不同的插件来请求相机的权限,即 cordova-plugin-qrscanner 和 phonegap-plugin-barcodescanner 一起安装,就会导致这个问题。

    删除任一插件

    ionic cordova plugin remove phonegap-plugin-barcodescanner
    

    ionic cordova plugin remove cordova-plugin-qrscanner
    

    【讨论】:

      【解决方案2】:

      是的。@Jay 是对的。因为我的 ionic 项目安装了两个不同的插件,它们需要相机的许可。 cordova-plugin-qrscanner 和 cordova-plugin-cszbar,删除其中一个插件然后工作。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2018-10-18
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-09-17
        相关资源
        最近更新 更多