cancel
Showing results for 
Search instead for 
Did you mean: 

Custom developed NativeScript plugin to include in MDK client

04-27-2021 12:10 AM
CRVMANISH Contributor
2166 views 13 comments Go to solution
0 Likes
SAP Managed Tags
Subscribe

Hi Experts,

I have developed plugin , i have not published the plugin.

How can i give local reference/path of plugin when building MDK client?

Please suggest.

Regards

Manish

0 Likes

Accepted Solutions (1)

Accepted Solutions (1)

bill_froelich
Product and Topic Expert
Product and Topic Expert
0 Likes

Manish,

Taking a look at your .mdkrpoject folder structure there are a few things that need adjustment to match the sample. I think once you get these adjusted your plugin will be installed. In particular, the extensions folder can contain multiple extension controls. Therefore each extension control needs to be contained in their own folder with a common structure for each one. I have mocked up your project with the updated structure.

Additionally, the NSPlugins reference in the MDKProject.json will attempt to add the plugin from the public repositories. If you plugin is in the extensions folder you should not list it in the NSPlugins. I would also recommend you use a bundle id that is unique to your organization to avoid any possible conflicts with SAP created apps.

Your package.json also needs to reference the Nativescript versions instead of the MDK version. Here is an updated version that I think is correct for your plugin.

Give this a shot and let me know if this fixes the install issue.

--Bill

CRVMANISH
Contributor
0 Likes

Hi bill.froelich

Thanks , i am able to proceed , now when i install it on device it is conflicting with my Android manifest file,

android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"

any idea on resolving android manifest error , i tried to replace but does not work ?

/Users/manishmeshram/Downloads/MDK_SDK_5_1_5_001_Notarized/MDKClient_SDK/RF MDK Client/platforms/android/app/src/main/AndroidManifest.xml:22:3-32 Error:
        Attribute application@icon value=(@drawable/icon) from AndroidManifest.xml:22:3-32
        is also present at [:app-release:] AndroidManifest.xml:13:9-43 value=(@mipmap/ic_launcher).
        Suggestion: add 'tools:replace="android:icon"' to <application> element at AndroidManifest.xml:18:2-68:16 to override.
/Users/manishmeshram/Downloads/MDK_SDK_5_1_5_001_Notarized/MDKClient_SDK/RF MDK Client/platforms/android/app/src/main/AndroidManifest.xml:23:3-39 Error:
        Attribute application@label value=(@string/mdk_app_name) from AndroidManifest.xml:23:3-39
        is also present at [:app-release:] AndroidManifest.xml:14:9-41 value=(@string/app_name).
        Suggestion: add 'tools:replace="android:label"' to <application> element at AndroidManifest.xml:18:2-68:16 to override.


Execution failed for task ':app:processDebugManifest'.
Manifest merger failed with multiple errors, see logs


Unable to apply changes on device: 18214522503092. Error is: Command ./gradlew failed with exit code 1.
bill_froelich
Product and Topic Expert
Product and Topic Expert
0 Likes

Do you have anything in your App_Resources that would be overwriting the Manifest or is this the default generated Manifest?

Also what version of Android OS are you trying to install this on?

CRVMANISH
Contributor
0 Likes

My plugin AAR lib android manifest file it is conflicting with MDK manifest file , i will try to remove from my AAR and rebuild to see if it resolves.

Android version 7.1.2.

Regards

Manish

CRVMANISH
Contributor
0 Likes

Hi bill.froelich

It worked by modifying my manifest, when plugin got installed it added as "CraveInfoTechScanner_craveinfotech-zebra-scanner" in plugin folder.

When i call my plugin functions in MDK rule should i reference it as "craveinfotech-zebra-scanner" or "CraveInfoTechScanner_craveinfotech-zebra-scanner"?

Example : var ZebraPlugin = require("craveinfotech-zebra-scanner");

Regards,

Manish

bill_froelich
Product and Topic Expert
Product and Topic Expert
0 Likes

You would reference it as the name of the plugin as specified in the package.json. In your example that would be craveinfotech-zebra-scanner.

Answers (1)

Answers (1)

bill_froelich
Product and Topic Expert
Product and Topic Expert
0 Likes

You can put your plugin into the extensions folder in your .mdkproject using the following structure. You can name your Extension and Plugin whatever you want but I recommend no spaces in the folder/file names. When you run create client it will automatically copy it to the correct location in your MDK client.

CRVMANISH
Contributor
0 Likes

Hi bill.froelich

I don't have extension control , in this case where should plugin folder reside?

Regards

Manish

bill_froelich
Product and Topic Expert
Product and Topic Expert
0 Likes

It is still an extension just with no control portion so the controls folder will be empty. You should put your plugin in the plugin folder above and keep the structure indicated.

--Bill

CRVMANISH
Contributor
0 Likes

Hi bill.froelich ,

I am getting below error.

Is there way to give file path , in my sample app i used this way and my plugin works without publishing in npm.

"dependencies": { "@nativescript/core": "~8.0.0", "@nativescript/theme": "~3.0.1", "craveinfotech-zebra-scanner": "file:..\\craveinfotech-zebra-scanner"

Error log.

Customizing VersionInfo.json file for Android Settings app
Updating SAPFiori.h
Installing application dependencies
Removing NativeScript plugin craveinfotech-zebra-scanner
Plugin "craveinfotech-zebra-scanner" is not installed.


Plugin "craveinfotech-zebra-scanner" is not installed.


Failed to remove craveinfotech-zebra-scanner plugin.
Installing NativeScript plugin: craveinfotech-zebra-scanner
Command npm failed with exit code 1 Error output: 
 npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/craveinfotech-zebra-scanner - Not found
npm ERR! 404 
npm ERR! 404  'craveinfotech-zebra-scanner@latest' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404 
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.


npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/manishmeshram/.npm/_logs/2021-04-27T16_52_12_023Z-debug.log




Command npm failed with exit code 1 Error output: 
 npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/craveinfotech-zebra-scanner - Not found
npm ERR! 404 
npm ERR! 404  'craveinfotech-zebra-scanner@latest' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404 
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.


npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/manishmeshram/.npm/_logs/2021-04-27T16_52_12_023Z-debug.log

bill_froelich
Product and Topic Expert
Product and Topic Expert
0 Likes

Can you share your expanded directory structure of your .mdkproject (you can leave metadata collapsed if you are bundling the app in there as well) along with the contents of your plugin package.json?

In your MDKProject.json, the only reference to your extension should be in the externals but only if you are bundling the metadata by default with the client. You should not list it in the NSPlugins.

CRVMANISH
Contributor
0 Likes

Hi bill.froelich

I tried excluding plugin from NSPlugins but then it does not add my plugin.

Below is my project structure.

Plugin json file

DC
Explorer
0 Likes

Hi Manish

Did you get this Working??? We are looking at doing something similar and would appreciate any help / guidance.

We looking are getting a plugin that will give us access to the native barcode device api/sdk

Appreciate you help with this

Cheers

Dharmesh