EddyVerbruggen / nativescript-secure-storage

:closed_lock_with_key: NativeScript plugin for secure local storage of fi. passwords
MIT License
111 stars 26 forks source link

Nativescript 3.4.0 Webpack giving a 'Cannot read property 'init' of undefined' error. #13

Closed skhye05 closed 6 years ago

skhye05 commented 6 years ago

I am trying the plugin on nativescript 3.4.0 angular and when i am using webpack i am getting the following error:

JS: ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'init' of undefined JS: TypeError: Cannot read property 'init' of undefined

which is related to this portion of the plugin code: function SecureStorage() { this.hawk = com.orhanobut.hawk.Hawk.init(utils.ad.getApplicationContext()).build(); }

What could be the issue here?

shorttermdaily commented 6 years ago

I have same issue on nativescript 3.4.0 and 3.4.1 first > $ tns info nativescript / 3.4.1 / 3.4.1 / up to date tns-core-modules / 3.4.0 / 3.4.0 / up to date tns-android / 3.4.1 / 3.4.1 / up to date

second> $ tns update next nativescript / 3.4.1 / 3.4.1 / up to date tns-core-modules / 4.0.0-2018-01-08-02 / 3.4.0 / up to date tns-android / 3.4.1-2018-01-12-01 / 3.4.1 / update available

And then, the issue was solved. ... I don't know how can this soled the issue. but It was good solution to me. I hope this solution will be helpful to you. Thank you for reading this post that written by my unskilled English. ps. I hope somebody will post about how could this solution have made problem solved.

jomis commented 6 years ago

Same problem for me with the following versions.

│ nativescript │ 3.4.1 │ 3.4.1 │ Up to date │ │ tns-core-modules │ 3.4.0 │ 3.4.0 │ Up to date │ │ tns-android │ 3.4.1 │ 3.4.1 │ Up to date │ │ tns-ios │ 3.4.1 │ 3.4.1 │ Up to date │

It works fine on iOS but exits with the above error on Android. The upgrade to next solution is not an option since this usually is not recommend for production releases.

gummibjorn commented 6 years ago

i think in the nativescript/android-runtime version 3.4.0 exists a bug regarding plugin dependencies. I assume this error is caused by a missing package (com.orhanobut.hawk) which is a secure-storage implementation for android.

i don't think there is a way for the plugin developer to fix this issue from his side.

the bug mentioned is fixed in android-runtime version 3.4.1

see PR #918

jacopo69 commented 6 years ago

I had the same problem. After uninstalling the app on device, removing the platform (tns platform remove android) and readding the platform (tns platform add android) I solved.

mustafacagataytulun commented 6 years ago

Confirming @jacopo69, a tns platform remove android and tns platform add android command chain is definitely required when you first add nativescript-secure-storage plugin to your NativeScript project.

EddyVerbruggen commented 6 years ago

That's true for all plugins wrapping native libraries.

aaayushsingh commented 6 years ago

I am still facing this issue. The above steps didn't work for me.