ionic3项目打包报错的问题,添加插件之后打包失败

发布于 2022-09-11 16:53:06 字数 6774 浏览 12 评论 0

新安装的一个ionic3的空白项目,我打包apk一切正常。
但是,为了测试一下如何调用native api,我在文档中找了一个关于二维码扫码的功能模块 QR Scanner来测试。
照文档的步骤安装 :
$ ionic cordova plugin add cordova-plugin-qrscanner
$ npm install --save @ionic-native/qr-scanner
于是报了下了的错

[ERROR] An error occurred while running cordova build android (exit code 1):

    (truncated) ... Lib:preReleaseBuild UP-TO-DATE
    :CordovaLib:checkReleaseManifest
    :CordovaLib:prepareReleaseDependencies
    :CordovaLib:compileReleaseAidl
    :CordovaLib:compileReleaseNdk UP-TO-DATE
    :CordovaLib:copyReleaseLint UP-TO-DATE
    :CordovaLib:mergeReleaseShaders
    :CordovaLib:compileReleaseShaders
    :CordovaLib:generateReleaseAssets
    :CordovaLib:mergeReleaseAssets
    :CordovaLib:mergeReleaseProguardFiles UP-TO-DATE
    :CordovaLib:packageReleaseRenderscript UP-TO-DATE
    :CordovaLib:compileReleaseRenderscript
    :CordovaLib:generateReleaseResValues
    :CordovaLib:generateReleaseResources
    :CordovaLib:packageReleaseResources
    :CordovaLib:processReleaseManifest
    :CordovaLib:generateReleaseBuildConfig
    :CordovaLib:processReleaseResources
    :CordovaLib:generateReleaseSources
    :CordovaLib:incrementalReleaseJavaCompilationSafeguard
    :CordovaLib:compileReleaseJavaWithJavac
    :CordovaLib:compileReleaseJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution,
    etc.).
    ע: ijЩ�����ļ�ʹ�û?����ѹ�ʱ�� API��
    ע: �й���ϸ��Ϣ, ��ʹ�� -Xlint:deprecation ���±��롣
    :CordovaLib:processReleaseJavaRes UP-TO-DATE
    :CordovaLib:transformResourcesWithMergeJavaResForRelease
    :CordovaLib:transformClassesAndResourcesWithSyncLibJarsForRelease
    :CordovaLib:mergeReleaseJniLibFolders
    :CordovaLib:transformNative_libsWithMergeJniLibsForRelease
    :CordovaLib:transformNative_libsWithSyncJniLibsForRelease
    :CordovaLib:bundleRelease
    :prepareComAndroidSupportAppcompatV72310Library
    :prepareComAndroidSupportSupportV42310Library
    :prepareComJourneyappsZxingAndroidEmbedded330Library
    :prepareDebugDependencies
    :compileDebugAidl
    :compileDebugRenderscript
    :generateDebugBuildConfig
    :generateDebugResValues
    :generateDebugResources
    :mergeDebugResources
    :processDebugManifest
    :processDebugResources
    :generateDebugSources
    :incrementalDebugJavaCompilationSafeguard
    :compileDebugJavaWithJavac
    :compileDebugJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.).
    D:\my_work\ioinc\ionic-cordova-demo\platforms\android\src\com\bitpay\cordova\qrscanner\QRScanner.java:21: ����:
    �Ҳ�������
    import org.apache.cordova.PermissionHelper;
                              ^
       ����:   �� PermissionHelper
       �: ����� org.apache.cordova
    D:\my_work\ioinc\ionic-cordova-demo\platforms\android\src\com\bitpay\cordova\qrscanner\QRScanner.java:398: �� ��:
    �Ҳ�������
                 if(!PermissionHelper.hasPermission(this, p))
                     ^
       ����:   ���� PermissionHelper
       �: �� QRScanner
    D:\my_work\ioinc\ionic-cordova-demo\platforms\android\src\com\bitpay\cordova\qrscanner\QRScanner.java:407: �� ��:
    �Ҳ�������
             PermissionHelper.requestPermissions(this, requestCode, permissions);
             ^
       ����:   ���� PermissionHelper
       �: �� QRScanner
    ע: ijЩ�����ļ�ʹ�û?����ѹ�ʱ�� API��
    ע: �й���ϸ��Ϣ, ��ʹ�� -Xlint:deprecation ���±��롣
    ע:
    D:\my_work\ioinc\ionic-cordova-demo\platforms\android\src\com\bitpay\cordova\qrscanner\QRScanner.javaʹ���� δ�����?�ȫ�IJ�����
    ע: �й���ϸ��Ϣ, ��ʹ�� -Xlint:unchecked ���±��롣
    3 ������
    :compileDebugJavaWithJavac FAILED

    FAILURE: Build failed with an exception.

    * What went wrong:
    Execution failed for task ':compileDebugJavaWithJavac'.
    > Compilation failed; see the compiler error output for details.

    * 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: 11.76 secs
    Error: cmd: Command failed with exit code 1 Error output:
    ע: ijЩ�����ļ�ʹ�û?����ѹ�ʱ�� API��
    ע: �й���ϸ��Ϣ, ��ʹ�� -Xlint:deprecation ���±��롣
    ע: ijЩ�����ļ�ʹ�û?����ѹ�ʱ�� API��
    ע: �й���ϸ��Ϣ, ��ʹ�� -Xlint:deprecation ���±��롣
    D:\my_work\ioinc\ionic-cordova-demo\platforms\android\src\com\bitpay\cordova\qrscanner\QRScanner.java:21: ����:
    �Ҳ�������
    import org.apache.cordova.PermissionHelper;
                              ^
       ����:   �� PermissionHelper
       �: ����� org.apache.cordova
    D:\my_work\ioinc\ionic-cordova-demo\platforms\android\src\com\bitpay\cordova\qrscanner\QRScanner.java:398: �� ��:
    �Ҳ�������
                 if(!PermissionHelper.hasPermission(this, p))
                     ^
       ����:   ���� PermissionHelper
       �: �� QRScanner
    D:\my_work\ioinc\ionic-cordova-demo\platforms\android\src\com\bitpay\cordova\qrscanner\QRScanner.java:407: �� ��:
    �Ҳ�������
             PermissionHelper.requestPermissions(this, requestCode, permissions);
             ^
       ����:   ���� PermissionHelper
       �: �� QRScanner
    ע: ijЩ�����ļ�ʹ�û?����ѹ�ʱ�� API��
    ע: �й���ϸ��Ϣ, ��ʹ�� -Xlint:deprecation ���±��롣
    ע:
    D:\my_work\ioinc\ionic-cordova-demo\platforms\android\src\com\bitpay\cordova\qrscanner\QRScanner.javaʹ���� δ�����?�ȫ�IJ�����
    ע: �й���ϸ��Ϣ, ��ʹ�� -Xlint:unchecked ���±��롣
    3 ������

    FAILURE: Build failed with an exception.

    * What went wrong:
    Execution failed for task ':compileDebugJavaWithJavac'.
    > Compilation failed; see the compiler error output for details.

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

_
请问这是什么原因。

然后我就把该插件重新remove掉 :ionic cordova plugin remove cordova-plugin-qrscanner
再打包又能成功了。

一定是插件安装导致的问题请问何解???### 问题描述

ionic info :

@ionic/cli-utils  : 1.12.0
ionic (Ionic CLI) : 3.12.0

global packages:

cordova (Cordova CLI) : 6.5.0

local packages:

@ionic/app-scripts : 3.0.0
Cordova Platforms  : none
Ionic Framework    : ionic-angular 3.7.1

System:

Android SDK Tools : 24.4.1
Node              : v8.12.0
npm               : 6.4.1
OS                : Windows 10

Misc:

backend : pro

问题出现的环境背景及自己尝试过哪些方法

相关代码

// 请把代码文本粘贴到下方(请勿用图片代替代码)

你期待的结果是什么?实际看到的错误信息又是什么?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文