Ionic-安装文件加密插件后无法构建

时间:2018-08-05 16:51:08

标签: file cordova ionic-framework encryption build

我用Ionic创建了一个空白项目,并安装了File Encryption插件。但是,甚至没有编写任何代码,尝试构建项目时出现以下错误:

    C:\Users\Zel\Desktop\a\platforms\android\src\com\disusered\Safe.java:120: error: cannot find symbol

      CRYPTO = new Crypto(new SharedPrefsBackedKeyChain(CONTEXT), new SystemNativeCryptoLibrary());
                              ^
  symbol:   class SharedPrefsBackedKeyChain
  location: class Safe
Note: Some input files use or override a deprecated API.
:compileDebugJavaWithJavac FAILED

Note: Recompile with -Xlint:deprecation for details.
2 errors

FAILURE: Build failed with an exception.

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


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

Total time: 11.002 secs
(node:14276) UnhandledPromiseRejectionWarning: Error: cmd: 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: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
C:\Users\Zel\Desktop\a\platforms\android\src\com\disusered\Safe.java:26: error: package com.facebook.android.crypto.keychain does not exist
import com.facebook.android.crypto.keychain.SharedPrefsBackedKeyChain;
                                           ^
C:\Users\Zel\Desktop\a\platforms\android\src\com\disusered\Safe.java:120: error: cannot find symbol
      CRYPTO = new Crypto(new SharedPrefsBackedKeyChain(CONTEXT), new SystemNativeCryptoLibrary());
                              ^
  symbol:   class SharedPrefsBackedKeyChain
  location: class Safe
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
2 errors

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.
    at ChildProcess.whenDone (C:\Users\Zel\Desktop\a\platforms\android\cordova\node_modules\cordova-common\src\superspawn.js:169:23)
    at emitTwo (events.js:126:13)
    at ChildProcess.emit (events.js:214:7)
    at maybeClose (internal/child_process.js:925:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
(node:14276) 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:14276) [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.

通过运行ionic info,我得到以下输出:

    cli packages: (C:\Users\Zel\AppData\Roaming\npm\node_modules)

    @ionic/cli-utils  : 1.19.2
    ionic (Ionic CLI) : 3.20.0

global packages:

    cordova (Cordova CLI) : 8.0.0

local packages:

    @ionic/app-scripts : 3.1.11
    Cordova Platforms  : android 6.3.0
    Ionic Framework    : ionic-angular 3.9.2

System:

    Android SDK Tools : 26.1.1
    Node              : v8.11.3
    npm               : 5.6.0
    OS                : Windows 10

我尝试了一些发现的事情,但是没有任何效果。 如果我使用的是Android 6.2.0,则可以构建该项目,但这告诉我实际上并没有安装该插件!

我使用的插件版本是最新的(2.0.1)

希望你们可以在这里帮我

谢谢。

2 个答案:

答案 0 :(得分:1)

尝试这个

在platform / android / cordova-safe / starter-conceal.gradle中对此进行更改

compile('com.facebook.conceal:conceal:1.0.0@aar') 对此 编译('com.facebook.conceal:conceal:2.0.1@aar')

这对我有用。

答案 1 :(得分:0)

打开platforms/android/cordova-safe/starter-conceal.gradle,然后将 com.facebook.conceal:conceal 的版本从 1.0.0 更新到 1.1.3 ,因此代码现在应该是

dependencies {
  compile('com.facebook.conceal:conceal:1.1.3@aar') {
    transitive = true
  }
}