abhayastudios / nativescript-contacts-lite

This nativescript-contacts-lite plugin provides pretty fast read-only access to the iOS and Android contact directory.
MIT License
13 stars 7 forks source link

Compilation failure on android with webpack #1

Closed l0stpenguin closed 7 years ago

l0stpenguin commented 7 years ago

Hi, i tried using your plugin with webpack but it fails on android.

To reproduce: Create a sample app based on default angular template: Add the webpack plugin + nativescript-contacts-lite + worker loader Add some codes using the web worker

Run the bundled project

npm run start-android-bundle 

Gradle fails at :asbg:generateBindings

Warning: there already is an extend called com.tns.FragmentClass.
Warning: The static binding generator will generate extend from:vendor.js implementation
:asbg:generateBindings
Exception in thread "main" java.io.IOException: File already exists. This may lead to undesired behavior.
Please change the name of one of the extended classes.
File:/Users/mevindhunnooa/Documents/workspace/my-app-name/platforms/android/src/main/java/com/tns/FragmentClass.java Class: com.tns.FragmentClass
        at org.nativescript.staticbindinggenerator.Generator.writeBindings(Generator.java:68)
        at org.nativescript.staticbindinggenerator.Main.main(Main.java:15)
:asbg:generateBindings FAILED

FAILURE: Build failed with an exception.

According to #778, This occurs because the plugin loads the tns modules which are already in the vendor.ts. I even tried using android@next version but it still fails. Here is a sample project with minimalistic code to reproduce https://github.com/mevinDhun/nativescript-webpack-error-app

Is there any way to fix this?

Thanks

abhayastudios commented 7 years ago

Hi Mevin,

I am traveling until next week, so I am less available to check things. However, I was able to run with webpack last time I checked (granted it was with NS 2.5). Thanks for the demo project, I will get back to you soon.

Cheers!

abhayastudios commented 7 years ago

@mevinDhun I was able to reproduce with your sample project. However, since this seems to be an issue with the android runtime (see my addition to this issue, I don't think I have anything to change for now.

However, as a work around you can do the following:

Then running npm run start-android-bundle will work. I will leave this issue open for now and keep an eye out to see when the issues with web workers will be fixed.

l0stpenguin commented 7 years ago

@abhayastudios The getContacts will block the UI and is not suitable for my app. Using webpack is not a must for me right now, hence i can skip it for android. I will wait for 778 to be resolved and then will try to integrate wepack on my android version. Thanks

alexandruantonica commented 7 years ago

@abhayastudios Did you find any solution for getContactsWorker to work on Android ? According to 778 the issues with web workers was solved.

abhayastudios commented 7 years ago

@alexandruantonica Indeed it is supposed to be released with NS 3.2. I haven't gotten around trying it yet in the @next build. Will update here when I get a chance.

abhayastudios commented 7 years ago

Fixed in NS3.2 with bb9f85a020ca718622cae3ca163c635b5043d7d5 and nativescript-dev-webpack v0.8.0.