Skip to content

Unable to call plugin's native code if application has been build before adding the plugin #1293

@rosen-vladimirov

Description

@rosen-vladimirov

Environment
Provide version numbers for the following components (information can be retrieved by running tns info in your project folder or by inspecting the package.json of the project):

  • CLI: 5.2.0
  • Cross-platform modules: 5.2.1
  • Android Runtime: 5.2.0
  • iOS Runtime (if applicable): Not applicable
  • Plugin(s): nativescript-feedback 1.3.6, but check steps to reproduce when you should add it to your project.

Describe the bug
In case you have build your application and add new plugin with native code after that, rebuilding of app does not use the new plugin's aar, so native methods cannot be called from application's code.
I.e. when you create an application and build it, after that you add a plugin, which has native code and run the application on device/emulator (NOTE: you have not deleted the platforms dir), the application runs fine, but the plugin's code is not working as JS code cannot call the native methods.

To Reproduce
You can use the project from this repository: https://github.com/rosen-vladimirov/app-feedback-plugin-issue
As described in its README.md, steps to reproduce are:

  1. Clone this repository: git clone https://github.com/rosen-vladimirov/app-feedback-plugin-issue.git
  2. Get to the project dir: cd app-feedback-plugin-issue
  3. Build the project: tns build android
  4. Now add nativescript-feedback plugin: npm i --save nativescript-feedback
  5. Open app/main-view-model.js and uncomment the commented sections. This way once you tap on the button, you will see a notification.
  6. Run tns run android
  7. Tap the button - no notification is shown.
  8. Stop tns run android command with Ctrl + C
  9. Delete platforms directory: rm -rf platforms
  10. Run tns run android again.
  11. Once application is running, tap the button on device - you should see the notification now.

Expected behavior
Users should be able to add plugins and the build process should respect them no matter if application has been build before that.

Sample project
https://github.com/rosen-vladimirov/app-feedback-plugin-issue

Additional context
It seems the problem is in extractAllJars gradle task which is reported as UP-TO-DATE, no matter we've just added a new .aar file to the project.
Seems related to: #1257

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions