[HealthPlugin] Fails when generating Android app

Forge Component
(3)
Published on 2019-07-18 by Sofia Mourato
3 votes
Published on 2019-07-18 by Sofia Mourato

Generating Android app fails on Outsystems 11 with the following error log:


==================================================

/tmp/build/source/platforms/android/src/org/apache/cordova/health/HealthPlugin.java:574: error: cannot find symbol
            builder.addScope(new Scope(Scopes.FITNESS_BLOOD_GLUCOSE_READ));
                                             ^
  symbol:   variable FITNESS_BLOOD_GLUCOSE_READ
  location: class Scopes
/opt/NativeBuilder/builds/5b5601f9-ff4d-4a06-950a-c6d746ee4d98/source/platforms/android/src/org/apache/cordova/health/HealthPlugin.java:576: error: cannot find symbol
            builder.addScope(new Scope(Scopes.FITNESS_BLOOD_GLUCOSE_READ_WRITE));
                                             ^
  symbol:   variable FITNESS_BLOOD_GLUCOSE_READ_WRITE
  location: class Scopes
/opt/NativeBuilder/builds/5b5601f9-ff4d-4a06-950a-c6d746ee4d98/source/platforms/android/src/org/apache/cordova/health/HealthPlugin.java:579: error: cannot find symbol
            builder.addScope(new Scope(Scopes.FITNESS_BLOOD_PRESSURE_READ));
                                             ^
  symbol:   variable FITNESS_BLOOD_PRESSURE_READ
  location: class Scopes
/opt/NativeBuilder/builds/5b5601f9-ff4d-4a06-950a-c6d746ee4d98/source/platforms/android/src/org/apache/cordova/health/HealthPlugin.java:581: error: cannot find symbol
            builder.addScope(new Scope(Scopes.FITNESS_BLOOD_PRESSURE_READ_WRITE));
                                             ^
  symbol:   variable FITNESS_BLOOD_PRESSURE_READ_WRITE
  location: class Scopes
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
4 errors

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

* Get more help at https://help.gradle.org

BUILD FAILED in 4s
Error: /opt/NativeBuilder/builds/5b5601f9-ff4d-4a06-950a-c6d746ee4d98/source/platforms/android/gradlew: Command failed with exit code 1 Error output:
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
/opt/NativeBuilder/builds/5b5601f9-ff4d-4a06-950a-c6d746ee4d98/source/platforms/android/src/org/apache/cordova/health/HealthPlugin.java:574: error: cannot find symbol
            builder.addScope(new Scope(Scopes.FITNESS_BLOOD_GLUCOSE_READ));
                                             ^
  symbol:   variable FITNESS_BLOOD_GLUCOSE_READ
  location: class Scopes
/opt/NativeBuilder/builds/5b5601f9-ff4d-4a06-950a-c6d746ee4d98/source/platforms/android/src/org/apache/cordova/health/HealthPlugin.java:576: error: cannot find symbol
            builder.addScope(new Scope(Scopes.FITNESS_BLOOD_GLUCOSE_READ_WRITE));
                                             ^
  symbol:   variable FITNESS_BLOOD_GLUCOSE_READ_WRITE
  location: class Scopes
/opt/NativeBuilder/builds/5b5601f9-ff4d-4a06-950a-c6d746ee4d98/source/platforms/android/src/org/apache/cordova/health/HealthPlugin.java:579: error: cannot find symbol
            builder.addScope(new Scope(Scopes.FITNESS_BLOOD_PRESSURE_READ));
                                             ^
  symbol:   variable FITNESS_BLOOD_PRESSURE_READ
  location: class Scopes
/opt/NativeBuilder/builds/5b5601f9-ff4d-4a06-950a-c6d746ee4d98/source/platforms/android/src/org/apache/cordova/health/HealthPlugin.java:581: error: cannot find symbol
            builder.addScope(new Scope(Scopes.FITNESS_BLOOD_PRESSURE_READ_WRITE));
                                             ^
  symbol:   variable FITNESS_BLOOD_PRESSURE_READ_WRITE
  location: class Scopes
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
4 errors

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

* Get more help at https://help.gradle.org

BUILD FAILED in 4s

[2018-10-02T15:20:51.735Z] [ERROR] Build failed with the following error: Error compiling Cordova plugin: org/apache/cordova/health/HealthPlugin.java:574: error: cannot find symbol.
[2018-10-02T15:20:51.735Z] [INFO] Remove debug/release signing properties
[2018-10-02T15:20:51.736Z] [INFO] Zipping application source...
[2018-10-02T15:21:06.082Z] [INFO] Application was not successfully generated!
[2018-10-02T15:21:06.082Z] [INFO] Execution time: 92413ms

Hi Denis,

This component was released for the platform version 10 and I didn't tested it on version 11 yet.
I'll try to do it as soon as I can and if I have news I'll let you know.

Kind regards,
Sofia

Thanks Sofia!

Hi Denis,

I was testing this in an OutSystems 11 environment and I had no issues on generating the app for an Android device. Nevertheless, I've just uploaded a new version of the component and its demo application to the Forge.

Please, try to use the latest version and check if the error persists.
You can download the demo application (HealthPlugin Demo) to test the core functionality and please, don't forget to read the "Details" tab that helps you with the keystore generation you need to generate the Android app.

Kind regards,
Sofia

Sofia Mourato wrote:

Hi Denis,

I was testing this in an OutSystems 11 environment and I had no issues on generating the app for an Android device. Nevertheless, I've just uploaded a new version of the component and its demo application to the Forge.

Please, try to use the latest version and check if the error persists.
You can download the demo application (HealthPlugin Demo) to test the core functionality and please, don't forget to read the "Details" tab that helps you with the keystore generation you need to generate the Android app.

Kind regards,
Sofia

Hi Sofia,

I had the same issue too. 

When I dereference the health plugin, I am able to regenerate my application.
However, when I reference it,  I will have the same error as above.

I have attached the log too. 

Thank you. 

Hi Olivier,

What's the app you're trying to generate? It's the demo app available on the Forge or other that you've created?
If it's a different app, can you share it with me so I can do some tests on my side?

Kind regards,
Sofia Mourato

Sofia Mourato wrote:

Hi Olivier,

What's the app you're trying to generate? It's the demo app available on the Forge or other that you've created?
If it's a different app, can you share it with me so I can do some tests on my side?

Kind regards,
Sofia Mourato

I was trying to generate the app that I have created. It was working previously.

The current app that I have now has nothing because I had deleted All health-related component. 

I can still send you though. In which format? OAP or OML? 

Hi Olivier,

Sorry for the late response.
Yes please send me the OAP, but with the health plugin implemented (and causing you the issue), so I can try to reproduce from my site.

Kind regards,
Sofia Mourato

Hi Sofia, 


I might have to send you at a later date as I am having an issue with my personal cloud storage.

I will get back to you once I have sorted out that. 


Regards,

Olivier Cheah

Hey Sofia,


Any news regarding this topic?


I am also facing the same issue as Denis Mulder.


Regards,

Davide Periquito wrote:

Hey Sofia,


Any news regarding this topic?


I am also facing the same issue.


Regards,

Hi Davide,

What's the issue you are having currently?
Can you share some more details like the Platform Version, MABS and device OS?

Regards,
sofia

Sofia Mourato wrote:

Davide Periquito wrote:

Hey Sofia,


Any news regarding this topic?


I am also facing the same issue.


Regards,

Hi Davide,

What's the issue you are having currently?
Can you share some more details like the Platform Version, MABS and device OS?

Regards,
sofia


The android application is not generated, similar to Denis same log message.


 I am using OS11 + MABS 5. Am I missing something with the keystore?

Davide,

Did you generate the keystore and followed the steps described in the component details?
Without a keystore, the app will be not be generated.

Davide Periquito wrote:

Hey Sofia,


Any news regarding this topic?


I am also facing the same issue as Denis Mulder.


Regards,

Hey Davide. 

I had been facing the same issue as you guys yesterday and managed to solve it by copying the actions and entities/structures from the HealthPlugin to a new application i created, and referenced it instead.

It did the trick and allowed me to generate the Android version.


Regards,

Rodrigo


Rodrigo Alves wrote:

Davide Periquito wrote:

Hey Sofia,


Any news regarding this topic?


I am also facing the same issue as Denis Mulder.


Regards,

Hey Davide. 

I had been facing the same issue as you guys yesterday and managed to solve it by copying the actions and entities/structures from the HealthPlugin to a new application i created, and referenced it instead.

It did the trick and allowed me to generate the Android version.


Regards,

Rodrigo


Hi Rodrigo,

I was able to build an Android app without any issue, just using the correct keystore.
Can it be some additional dependency there that was causing the issue?

Kind regards,
Sofia


Hey,


Sorry, the generation of the Keystore wasn't something straightforward, and that wasn't my problem after all.


I am able to generate the application as a sandbox. But once I get the plugin on the right application everything falls apart. After a lot of "try and error" I manage to discover another weird relation, once I added onesignal plugin dependencies I wasn't able to build the application anymore.

So, if everything goes separete it works as expected once I get both dependencies together I get the error that Denis described.


Unfortunately, I still don't have a solution, I will implement Rodrigo's suggestion, and I will get back to the thread.


Hi Davide,

Ok it could be a dependency relationship issue then, which is not an easy thing to solve.
I'll also do some tests on my side and see if I can solve it.

Regards,
Sofia

Hey Sofia,


I can't say for sure, but i don't think so.

I'm using everything from your plugin with the exception of the cordova-plugin-health-master.zip resource. Same dependencies (CommonPlugin and System).

Regarding Davide's, i am also using the onesignal plugin and it works perfectly.


Regards,

Rodrigo

Rodrigo Alves wrote:

Hey Sofia,


I can't say for sure, but i don't think so.

I'm using everything from your plugin with the exception of the cordova-plugin-health-master.zip resource. Same dependencies (CommonPlugin and System).

Regarding Davide's, i am also using the onesignal plugin and it works perfectly.


Regards,

Rodrigo


So just to be clear, you removed all this part of the Extensibility Configurations? And are you still able to fetch all kinds of Data?


Ok Rodrigo,

So the zip was to solve an issue with the previous MABS version, and probably we can now remove it and use the extensibility to the Git repository.
I'll review this when I have and let you know if there are updates.

Thank you

Davide Periquito wrote:

Rodrigo Alves wrote:

Hey Sofia,


I can't say for sure, but i don't think so.

I'm using everything from your plugin with the exception of the cordova-plugin-health-master.zip resource. Same dependencies (CommonPlugin and System).

Regarding Davide's, i am also using the onesignal plugin and it works perfectly.


Regards,

Rodrigo


So just to be clear, you removed all this part of the Extensibility Configurations? And are you still able to fetch all kinds of Data?


That is correct, i wasn't sure if that would solve it, however it all compiled and generated correctly. Everything other than that is the same as is in the original plugin.


Rodrigo Alves wrote:

Davide Periquito wrote:

Rodrigo Alves wrote:

Hey Sofia,


I can't say for sure, but i don't think so.

I'm using everything from your plugin with the exception of the cordova-plugin-health-master.zip resource. Same dependencies (CommonPlugin and System).

Regarding Davide's, i am also using the onesignal plugin and it works perfectly.


Regards,

Rodrigo


So just to be clear, you removed all this part of the Extensibility Configurations? And are you still able to fetch all kinds of Data?


That is correct, i wasn't sure if that would solve it, however it all compiled and generated correctly. Everything other than that is the same as is in the original plugin.


Hey guys,

I had a suspicion about something after replying to the post and was doing some tests to be sure. 

I am using it mostly for the HealthKit part of the plugin, so i have my app installed in an IPhone. After removing the extensibility config i generated the Android app and it was successfull, and since the app which i had installed (iOS) was working perfectly, i thought it was fixed. 

However i did not re-generate the iOS version of it, so the config was still active in the phone's app.

I've just attempted to generate the iOS version again without those configs and it failed to recognize the plugin which makes sense.

Sorry for the mistake, it seems that that way the error is not fixed :/.

Now it makes sense :)

Can you please try to use the extensibility with this URL (instead of the zip):
https://github.com/dariosalvi78/cordova-plugin-health.git

Please let me know if it worked.

Try this:

{
    "plugin" :{
        "url": "https://github.com/dariosalvi78/cordova-plugin-health.git"
    }
}

Sofia Mourato wrote:

Now it makes sense :)

Can you please try to use the extensibility with this URL (instead of the zip):
https://github.com/dariosalvi78/cordova-plugin-health.git

Please let me know if it worked.

Try this:

{
    "plugin" :{
        "url": "https://github.com/dariosalvi78/cordova-plugin-health.git"
    }
}

I have just tried it and unfortunately the error remains when generating the Android version.


Same error.


I am trying with the newer version of the one signal the same thing.

Can you please share with me the apps so I can test on my side?

Unfortunately, i can not, due to it not being a personal app..

Sofia Mourato wrote:

Can you please share with me the apps so I can test on my side?

Quick Update:

I managed to fix the issue on my side.

The error is due to a reference of 4 attributes from Google's API that have most likely been deprecated and/or updated to another version/name, hence it not finding them and throwing an exception.

Since i am not using the google fit side on my part, i simply saved the .zip file on my computer (resources), opened it and removed the FITNESS_BLOOD_GLUCOSE_READ  and other "ifs" (3 or 4 in total if i remember correctly) at around line 570 in the main code.

After saving, re-importing the new .zip, publishing the plugin and refreshing the dependencies/publishing on the main app, i successfully generated the app on Android.

If you don't need those particular readings, i would advise to do the same. However if you need them, i would advise to look for the more recent attributes which are in use perhaps.


Hi Rodrigo,

That's great information!
I'll investigate that (as soon as I have some time) and try to have a new version of the component.

Thank you!

Regards,
Sofia