disusered / cordova-safe

File encryption for Cordova.
MIT License
35 stars 22 forks source link

issue using 1.1 on meteor #6

Closed bgrayburn closed 8 years ago

bgrayburn commented 8 years ago

Seems cordova can't locate the com.facebook.crypto lib. I'm using cordova-safe in a meteor app so this may look a little different than a normal cordova debug output, but under the hood it really is just cordova. com.facebook.crypto.* java lib isn't listed as a dependency. Should it be? am I missing something else? Thank you! error below

[buildconfig] Generating BuildConfig class.
-pre-compile:
     [echo] Set jars path to: /media/Storage/emocha/platform-midot-mobile/app/.meteor/local/cordova-build/platforms/android/CordovaLib/ant-build/classes.jar
-compile:
    [javac] Compiling 31 source files to /media/Storage/emocha/platform-midot-mobile/app/.meteor/local/cordova-build/platforms/android/ant-build/classes
    [javac] /media/Storage/emocha/platform-midot-mobile/app/.meteor/local/cordova-build/platforms/android/src/com/disusered/Safe.java:21: error: package com.facebook.crypto does not exist
    [javac] import com.facebook.crypto.Crypto;
    [javac]                           ^
    [javac] /media/Storage/emocha/platform-midot-mobile/app/.meteor/local/cordova-build/platforms/android/src/com/disusered/Safe.java:22: error: package com.facebook.crypto does not exist
    [javac] import com.facebook.crypto.Entity;
    [javac]                           ^
    [javac] /media/Storage/emocha/platform-midot-mobile/app/.meteor/local/cordova-build/platforms/android/src/com/disusered/Safe.java:23: error: package com.facebook.crypto.exception does not exist
    [javac] import com.facebook.crypto.exception.CryptoInitializationException;
    [javac]                                     ^
    [javac] /media/Storage/emocha/platform-midot-mobile/app/.meteor/local/cordova-build/platforms/android/src/com/disusered/Safe.java:24: error: package com.facebook.crypto.exception does not exist
    [javac] import com.facebook.crypto.exception.KeyChainException;
    [javac]                                     ^
    [javac] /media/Storage/emocha/platform-midot-mobile/app/.meteor/local/cordova-build/platforms/android/src/com/disusered/Safe.java:25: error: package com.facebook.android.crypto.keychain does not exist
    [javac] import com.facebook.android.crypto.keychain.SharedPrefsBackedKeyChain;
    [javac]                                            ^
    [javac] /media/Storage/emocha/platform-midot-mobile/app/.meteor/local/cordova-build/platforms/android/src/com/disusered/Safe.java:26: error: package com.facebook.crypto.util does not exist
    [javac] import com.facebook.crypto.util.SystemNativeCryptoLibrary;
    [javac]                                ^
    [javac] /media/Storage/emocha/platform-midot-mobile/app/.meteor/local/cordova-build/platforms/android/src/com/disusered/Safe.java:37: error: cannot find symbol
    [javac]   private Crypto CRYPTO;
    [javac]           ^
    [javac]   symbol:   class Crypto
    [javac]   location: class Safe
    [javac] /media/Storage/emocha/platform-midot-mobile/app/.meteor/local/cordova-build/platforms/android/src/com/disusered/Safe.java:38: error: cannot find symbol
    [javac]   private Entity ENTITY;
    [javac]           ^
    [javac]   symbol:   class Entity
    [javac]   location: class Safe
    [javac] /media/Storage/emocha/platform-midot-mobile/app/.meteor/local/cordova-build/platforms/android/src/com/disusered/Safe.java:96: error: cannot find symbol
    [javac]     } catch (CryptoInitializationException e) {
    [javac]              ^
    [javac]   symbol:   class CryptoInitializationException
    [javac]   location: class Safe
    [javac] /media/Storage/emocha/platform-midot-mobile/app/.meteor/local/cordova-build/platforms/android/src/com/disusered/Safe.java:98: error: cannot find symbol
    [javac]     } catch (KeyChainException e) {
    [javac]              ^
    [javac]   symbol:   class KeyChainException
    [javac]   location: class Safe
    [javac] /media/Storage/emocha/platform-midot-mobile/app/.meteor/local/cordova-build/platforms/android/src/com/disusered/Safe.java:111: error: cannot find symbol
    [javac]       ENTITY = new Entity(password);
    [javac]                    ^
    [javac]   symbol:   class Entity
    [javac]   location: class Safe
    [javac] /media/Storage/emocha/platform-midot-mobile/app/.meteor/local/cordova-build/platforms/android/src/com/disusered/Safe.java:116: error: cannot find symbol
    [javac]       CRYPTO = new Crypto(new SharedPrefsBackedKeyChain(CONTEXT), new SystemNativeCryptoLibrary());
    [javac]                    ^
    [javac]   symbol:   class Crypto
    [javac]   location: class Safe
    [javac] /media/Storage/emocha/platform-midot-mobile/app/.meteor/local/cordova-build/platforms/android/src/com/disusered/Safe.java:116: error: cannot find symbol
    [javac]       CRYPTO = new Crypto(new SharedPrefsBackedKeyChain(CONTEXT), new SystemNativeCryptoLibrary());
    [javac]                               ^
    [javac]   symbol:   class SharedPrefsBackedKeyChain
    [javac]   location: class Safe
    [javac] /media/Storage/emocha/platform-midot-mobile/app/.meteor/local/cordova-build/platforms/android/src/com/disusered/Safe.java:116: error: cannot find symbol
    [javac]       CRYPTO = new Crypto(new SharedPrefsBackedKeyChain(CONTEXT), new SystemNativeCryptoLibrary());
    [javac]                                                                       ^
    [javac]   symbol:   class SystemNativeCryptoLibrary
    [javac]   location: class Safe
    [javac] Note: Some input files use or override a deprecated API.
    [javac] Note: Recompile with -Xlint:deprecation for details.
    [javac] Note: Some input files use unchecked or unsafe operations.
    [javac] Note: Recompile with -Xlint:unchecked for details.
    [javac] 14 errors
Command finished with error code 8: /media/Storage/emocha/platform-midot-mobile/app/.meteor/local/cordova-build/platforms/android/cordova/run --device
ERROR running one or more of the platforms: Error: /media/Storage/emocha/platform-midot-mobile/app/.meteor/local/cordova-build/platforms/android/cordova/run: Command failed with exit code 8
You may not have the required environment or OS to run this project
BUILD FAILED
/Users/bgrayburn/.meteor/android_bundle/android-sdk/tools/ant/build.xml:716: The following error occurred while executing this line:
/Users/bgrayburn/.meteor/android_bundle/android-sdk/tools/ant/build.xml:730: Compile failed; see the compiler error output for details.
Total time: 3 seconds
/media/Storage/emocha/platform-midot-mobile/app/.meteor/local/cordova-build/platforms/android/cordova/node_modules/q/q.js:126
                    throw e;
                          ^
Error code 1 for command: ant with args: debug,-f,/media/Storage/emocha/platform-midot-mobile/app/.meteor/local/cordova-build/platforms/android/build.xml,-Dout.dir=ant-build,-Dgen.absolute.dir=ant-gen
disusered commented 8 years ago

Ok I see the problem. Cordova uses Gradle for the Android build process, older versions used Ant. It seems Meteor uses the Ant version. I found an unaccepted PR regarding this: https://github.com/meteor/meteor/pull/4390

The way this was addressed previously was messy and error prone. I created a gradle file that downloaded the library, extracts it and copies it to the Android project. This was run automatically via an install hook that ran the gradle command, gradle getDeps.

So there's a few solutions... the automated ones would be through Gradle and a Hook, otherwise trying the meteor-cordova fork. The manual solutions would be downloading the support lib and adding to platforms/android manually.

Hope this helps somewhat!

disusered commented 8 years ago

I was advised to add an engine requirement to plugin.xml, this would fail the plugin install in this case. I am racking my brain for workarounds, I don't have as much experience with Meteor to approach this. I wouldn't like to bundle the dependency, it's very brute force, but would address these issues.

bgrayburn commented 8 years ago

Thanks for all the help! Sorry for the delay, got shifted to something else for a few days. I've decided for the moment to use your manual solution since it looks like meteor is in the process of switching over to utilize gradle.

I wanted to make sure I was adding the right files, is it all the files available here in the download section? (Conceal.jar, libconceal.jar, and contents of native binaries zip)

disusered commented 8 years ago

Yes, adding those contents to the Android project manually will work, the only bad part is you'd have to do it manually. As I noted in my earlier response, prior to official Gradle support I used Cordova hooks and a custom Gradle script that downloaded and uncompressed the library, then copied it to the right place, maybe those can be useful in setting up your Android libs/.

bgrayburn commented 8 years ago

awesome, just got it working using the gradle script! Sorry for the noob questions, this is new ground for me. Thanks again!

disusered commented 8 years ago

That's great news, happy to hear! Not at all, coming from a web background I didn't know any of the mobile tooling or ecosystem either, Cordova helped bridge those gaps. It's been a learning experience for me as well, thanks in large part to feedback and help from the community. Open source is pretty awesome :100: