Hi All,
I have gone through similar links where issues with custom plugin’s have mentioned, but my problem is different.
I included the newly created plugin but without even referring the plugin method anywhere in the ionic2 project (TypeScript / HTML ) and launching the project in simulator or real android device crashes! This sample plugin is supposed to show a toast message with input from user through CoolPlugin.java
Trial 1
- Created directory for plugin repository D:\NewPlugin
- Created sub directories a) D:\NewPlugin\src\android b) D:\NewPlugin\www
- Created File named CoolPlugin.java inside src\android
- Copied code from sample_tutorial to this file CoolPlugin.java which starts with public class CoolPlugin extends CordovaPlugin
- Inside www folder, JavaScript needs to be created CoolPlugin.js
- Copied sample JS file into CoolPlugin.js from the above mentioned sample tutorial
- Created plugin.xml with provided content
- Changes are made to references, id’s wherever required
- Now in IONIC2 part , created new project with ionic start cutePuppyPics --v2 using NodeJS Command Prompt
- Before this npm install -g ionic cordova command is already given in NodeJS Command prompt
- Navigated inside project named cutePuppyPics which is a starter blank application
- Command applied for adding android features cordova platform add android
- Updated the version of android to 5.1.1, as per cordova requirement with below command
- cordova platform update android@5.1.1
- To add plugin the following command is used
- plugman install --platform android –project </path/to/my/project/platforms/android> --plugin </path/to/my/plugin>
- navigated back to project parent folder and applied cordova build android
- Referred the plugin in targeted TypeScript where click of button will invoke a method with following code
- (window).plugins.CoolPlugin.showToast(‘Value from Ionic’);
- By including the CoolPlugin.js as per reference links [] gave error . And this is mentioned as wrong approach in ionic community discussions as well
- To run in actual device used the following command ionic run android –device
- Running on device crashes in the launch itself
Trial 2
- Removed the REFERENCES ONLY from TypeScript file in Ionic Project.
- Plugin is still included
- I had did because this step may be an error (window).plugins.CoolPlugin.showToast(‘Value from Ionic’);
- According to similar posts, an Interface needs to be created and used
- Compiled and deployed in Android device
- Even if removed reference of plugin from TypeScript file, running on device crashes in the launch itself
Trial 3
- I removed the added plugin from ionic project using cordova plugin remove<com.test.pluginone> command
- Build the project and try to run in device
- Now the project is getting loaded and running in real device!
Why this project not even loading in devices and crashes? Any clue?
In which step I am going wrong?
Any help is highly appreciated!