[Now Plugin MicroBlink] Android customization

[Now Plugin MicroBlink] Android customization

Forge Component
Published on 2015-12-30 by Rúben Gonçalves
0 votes
Published on 2015-12-30 by Rúben Gonçalves

I'm not a huge specialist in Android development, but do have experience after I did a lot of stuff while building our custom OutsystemsNow version. I think I'm missing something from customization steps here https://github.com/OutSystems/Cordova-Plugin-Micro-Blink-ID.
I have added repository and dependency to Gradle build file as described. The build is successfull, and the size of apk has risen from 3 Mb to 12 Mb - which I understand as there was a lot of something added.
But when I click a button - nothing happens. And OnNotify handler (on OutSystems side) is not being entered in debug. I think there is something more needed to be done to make it work. Is it?
I'm confused by "Installation" part in the steps: "Run the following command: cordova plugin add https://github.com/OutSystems/Cordova-Plugin-Micro-Blink-ID.git".
I didn't do this because I can't get where and how to "run this command". I'm using Windows, I don't have any program named "cordova". And is this step needed at all, as there is repository block in Gradle pointing to URL, which looks like it will download what's needed?
And do I need to install something for maven to work? (as that repository block references maven, but I don't remember ever installing it, and don't see it anywhere, but maybe it's somewhere built into Android studio).
Is there something needed to be added via java code there?
I have looked into sources of the eSpace, it looks understandble and nothing that might cause problems in that part, so I believe there is something missed in Android part.
Hi Igor,

To be honest, I haven't tried in the way you're describing. I typically install the plugins, using the command line interface, and for that you need to have node.js and cordova installed. (You can see the instructions in the cordova website).
BTW, when using the webblock, did you pass the id of a link or of a button? I've noticied that with links it may not work (it's on my todo list to check that).

Let me know, if you were able to solve it. 

Hi Ruben,

Thanks for the info about cordova - I wish this was on that information page (could you add it there?). Maybe for expert java developers this is natural, but I had no idea that I needed to install Node.js.
Unfortunately, now after I installed the plugin - my project is completely broken. :) Something is messed up with resources. First I started getting errors about several colour resources not found in layout. I have compared with the latest backup copy (we are not using source control for Java which makes things really hard!) and found that my colours XML was overwritten and everything I added myself was lost!
I returned it back, there were some other errors, I don't remember now, but I restored all the resources, and now I'm getting complilation errors "package R does not exists" everywhere I'm using resources.
This is weird and I have a feeling that I will spend at least a day fighting this problem, but well... it's Java. :)

As for the passed id - I'm using just div (it works with other OSNow functions, for example with barcode scanning, as I understand there is just "onclick" event added, and it works with most elements), but I checked with button also and there was no difference.
Hi Igor,
I tried install the plugin with last version of OutSystems Now code from Github and I can’t see the errors that you had.
The steps that i did to install the plugin were:
               repositories {
                    maven { url 'http://maven.microblink.com}
  • Add the dependency of the MicroBlink lib
    • compile 'com.microblink:blinkid:1.9.0@aar'
  • There is an additionally step that you need on OutSystems now code. Open the CordovaWebViewInterface.java and on the method startActivityForResult add the following validation
    • Replace this if
                         if (intent.getAction().contains("SCAN"))
    • Replace for this
                         if (intent.getAction() != null && intent.getAction().contains("SCAN"))
  • Finally, when you generate a license this is associated with package name, so when you run the app this needs to have the same package. To change the package of your app, open the gradle.properties and define on Application_ID the same package. After that, click on the Button sync project with gradle files (there is a button on top in Android Studio to do that);
Regarding the error that you have in your project, this can be related with you first copy the files and after install the plugin using cordova CLI, this might add duplicated resources to your project. My advise for this is you install the plugin in a new version of the code without the code you added before. 

Thanks, Vitor.

I did it again from the start, first installing the plugin and then doing modifications, but the result was the same. By the way, for plugin installation to work, there must be a class extending CordovaActivity, and it must be in the root of the package - otherwise there is error. I read that this is some "easter egg" without any functional meaning, so I have created an empty class.

Finally I found that the problem with my resources was because the plugin installation changed package name in AndroidManifest.xml to "com.outsystems.android". Actually I have found several places with this package specifiied and replaced them all just in case.
In AndroidManifest.xml, it also reset my version to number 1 (which made application updated to the "newer", in reality older, version after I installed it). There were also new permissions added, like read/write calendar, contacts, etc - I can't imagine why it might need them, so I removed them. Also elements were repositioned, but looks like without changes.
I have looked through other resources and found that a lot of translations were added (I had just 3 languages that we support), and while main (english) version of strings still has the values I have added, the other languages were just reset and so my translations were lost. I wish we had source control, because I'm not sure if there might be something else lost which I didn't find, and which might be noticed much later.

But now it works! Somewhat tricky for me to position it right to be scanned, but otherwise - magic.

Only that overwriting of resources and changes of values in the manifest is frustrating.
And also that apk has grown from 3 Mb to 12... but I guess nowadays application size doesn't matter.