GoogleCloudPlatform / fda-mystudies

FDA MyStudies
Other
61 stars 41 forks source link

[Android Configuration] 'Error, can't continue' message when running the Android app in both the emulator and on a mobile device #5123

Closed jaseva closed 1 year ago

jaseva commented 1 year ago

Hello,

I deployed v2.0.11 of the platform, and I am facing difficulties while configuring the Android application using the Android Configuration Instructions on this page: https://github.com/GoogleCloudPlatform/fda-mystudies/tree/master/Android.

I followed the instructions, but I have questions about some of the steps.

In step 1, the manual-android-bundle-id secret is missing from GCP secret manager since it was removed in v2.0.8, and I am not sure what replaced it.

In step 2, the api.properties file requires an appID value that should match the one manually set in GCP secret manager. However, since I deployed v2.0.11, I cannot find the manual-mobile-app-appid value that was set in GCP secret manager (as that was also removed from v2.0.8). I am wondering what the appID value should be, and if possible, please provide an example. Here is a link to what was removed in v2.0.8: https://github.com/GoogleCloudPlatform/fda-mystudies/blob/master/deployment/README.md#changes-to-secrets-when-upgrading-to-208-or-greater

I completed step 3 without issues though perhaps my deeplink_host is incorrect if the package name is wrong? I have kept my applicationID (app\build.gradle), APP_ID (api.properties), ENTITY package_name (strings.xml), packagename (app\google-services.json), and Android Bundle ID (Study Builder Portal\ App\ Developer Configurations), all the same name which is my "." naming convention. My urls for the Study Builder and Participant Manager both have hyphens as opposed to underscores between the and . syntax and it is required the applicationID have an underscore "_" value as opposed to a hyphen "-" value. So the value used for the subdomain has a hyphen between the two words as opposed to an underscore. Could this have impacted the deeplink host which is found in the strings.xml file?

image

In step 4, I believe I correctly configured Firebase since I can see analytics from attempting to load the deployed Android application.

For step 5, I followed the semi-automated deployment guide and skipped this step. I assume that I have connectivity since the configured app that I published in Study Builder has an associated study that is viewable in the Participant Manager portal.

In the mystudies_app_info_update_db_script.sql, I am confused by the comment that says the script should be run every time a new app is added through the Study Builder portal. Do I need to run this script in gcp console every time I add a new app through the Study Builder portal? An understanding of the process would be helpful when adding multiple apps through Study Builder portal.

Steps 6-8 were straightforward, and I did not have any questions related to them. Despite following the instructions, I cannot connect to the Android app either through my mobile phone or through the emulator in Android Studio.

Please see the screenshot of the error message I receive when deploying the app to both the emulator and a mobile device. I would appreciate any help or advice. Thank you.

image

jaseva commented 1 year ago

Hi @yugandhar-btc @naveenr-btc, would you have any insight into delpoying the Android app? The instructions seem outdated for v2.0.11 deployment and I am being thrown an error message when trying to connect to the Android app. It builds fine in Android Studio.

Shashank-btc commented 1 year ago

Hi @jaseva can you please share logs to get good idea about the error message because we are showing the same error message in many scenarios. Please do the needful.

jaseva commented 1 year ago

Hi @Shashank-btc ,

The error message is produced after the Android app builds and runs on the device and when I traced the error message, it is found in two files (SplashActivity.java, PasscodeSetupActivity.java) in the repository:

https://github.com/GoogleCloudPlatform/fda-mystudies/search?q=%22Error%2C+can%27t+continue%22

Android/app/src/main/java/com/harvard/SplashActivity.java Android/app/src/main/java/com/harvard/passcodemodule/PasscodeSetupActivity.java

A. Error Logs

Please see the attached error logs in csv format produced from 3 of the projects:

1. Error Logs from the Apps project

[REMOVED]

In the Apps project, it is complaining about IAM, sidecar, hydra-ic.

2. Error logs from the Data project

[REMOVED]

In the Data project, it is complaining about missing tables including the Patient, Questionnaire, FHIR.Patient, and FHIR.Questionnaire.

3. Error logs from the Network project

[REMOVED]

In the Network project, it is complaining about: Required 'compute.firewalls.update' permission for 'projects/[REMOVED FOR PRIVACY]-networks/global/firewalls/k8s-fw-l7--83ac8e4126e71592'

B. Resources

Please see the impacted resource types from affected projects.

1. Apps Project

Resource Types api, audited resource, gce_backend_service, k8s_container

2. Data Project

Resource Types bigquery_dataset, bigquery_resource

3. Network Project

Resource Types gce_firewall_rule

Comments

I tried refreshing the Kubernetes cluster and restarted the relevant pods to re-propogate the updated secrets to the applications and then updated the firewalls again to try to eliminate some of the errors though that doesn't look like it worked for me. I do notice that when I rebuild and run the app on the emulator, it takes longer to load the Android app as it attempts to connect however it still produces the same 'Error, can't continue' message.

Perhaps it continues to fail due to the missing database tables for the Patient, Questionnaire, FHIR.Patient, and FHIR.Questionnaire in the Data project? It seems in my case, I am having permission/ IAM issues, Firewall issue, and missing database tables.

I can confirm that all updates as per the v2.0.11 upgrade instructions are present in the various main.tf files through gcp console as per this link: https://github.com/GoogleCloudPlatform/fda-mystudies/blob/master/deployment/README.md#migration-to-cloud-healthcare-api-from-firestore-2011-upgrade

I also re-migrated the databases following these instructions to no resolve: https://github.com/GoogleCloudPlatform/fda-mystudies/blob/master/db-migration/README.md

I suppose the question would be is there something wrong with the configuration settings I used for Android as per the Android Configuration instructions or is there something wrong with the deployment process that is giving rise to the errors encountered?

Any insights would be appreciated.

Shashank-btc commented 1 year ago

Hi @jaseva thanks for the logs, can you please share the android studio logs for the better understanding. Please do the needful.

jaseva commented 1 year ago

Hi @Shashank-btc @yugandhar-btc , please see the attached log from Android Studio while building. Looks like it is failing and complaining:

Execution failed for task ':app:lint'.

Could not resolve all artifacts for configuration ':app:fdaDebugAndroidTestRuntimeClasspath'. Could not resolve org.jetbrains.kotlin:kotlin-stdlib:{strictly 1.3.20}.

Shashank-btc commented 1 year ago

@jaseva thanks for the android logs, can you please connect you mobile to your machine which already have build installed and can you open the app so that we will get the exact logs in the android studio, becasue which above logs we didnt fine exact error.

jaseva commented 1 year ago

Hi , I copied the logcat from Android Studio while my mobile device was connected with the app running.

Firebase is generating Anayltics from my attempts at loading the Android app. As per the server error logs above for the Apps, Data, and Network projects, do you think it is one of the impacted resources that are preventing the Android app from running? It is the SplashActivity.java and PasscodeSetupActivity.java files that have the "Error can't continue" message.

What resources should load when the Android app runs? Something fails there. Perhaps it could be related to my Android configuration settings?

jaseva commented 1 year ago

@Shashank-btc @yugandhar-btc I added this dependency to the app\build.gradle file as per the error message in the above Android Studio logcat file I attached:

// https://mvnrepository.com/artifact/org.jetbrains.kotlin/kotlin-stdlib-common implementation 'org.jetbrains.kotlin:kotlin-stdlib-common:1.3.20'

That seems to have resolved the error message regarding the org.jetbrains.kotlin:kotlin-stdlib-common:1.3.20 dependency that was missing.

After re-syncing the build.gradle and running the app I still experience the same connectivity issue when the Android app tries to load.

jaseva commented 1 year ago

@Shashank-btc in the logcat file while running the app on my Android phone, it is complaining about a Realm Key error.

jaseva commented 1 year ago

@bhoomikav16 do you happen to have insight to this 'Error, can't continue message'? It seems similar to this issue here you worked on:

https://github.com/GoogleCloudPlatform/fda-mystudies/issues/5097

Shashank-btc commented 1 year ago

@jaseve, Thanks for the information.

Please look into this particular file/class for making changes.

https://github.com/GoogleCloudPlatform/fda-mystudies/blob/master/Android/app/src/main/java/com/harvard/webservicemodule/apihelper/HttpRequest.java

Can you please add below line of code after line number 413 "Log.e("check","Response "+responseData);"

Also can you please share the logs.

jaseva commented 1 year ago

Hi @Shashank-btc , thanks for the info. I had to update your line of code as there must have been a conflict with another class named Log in the file:

android.util.Log.e("check"," Response "+ responseData);

I contacted GCP support, and we were able to resolve the firewall error in the Network project by creating 2 new custom permission roles and then adding to the service account:

compute.networks.updatePolicy compute.firewalls.update

I still have errors produced in the Apps and Data projects in the logs on GCP with the following resources impacted:

Apps Project Kubernetes Container Audited Resource Compute Engine Backend Service Produced API

Data Project BigQuery Dataset BigQuery

Slight Update (2023-03-02)

Findings: It appears that the error in BigQuery is looking into the FHIR tables. The role of the BigQuery here is for exploration and analysis from the FHIR resources. It seems that the tables missing are from the FHIR resource. Hence, the BigQuery tables will be created once the Android App is deployed or the FHIR store is created and exported into BigQuery.

I still have the issues regarding the errors in the Apps project and the error message when I try running the Android app in the emulator or on the mobile device from Android Studio.

jaseva commented 1 year ago

@Shashank-btc @yugandhar-btc Please see the updated comment from Google Support regarding the remaining issues I am experiencing:

"As for the errors[1] you are getting on the other project ‘[REMOVED FOR PRIVACY]-apps’, I have collaborated on this case with our GKE and GCE Infrastructure team. Based on our findings, this error is having permission issues with this service account[2] or the resource itself does not exist. Upon checking, we also did not find this on the list of service accounts that existed on the project itself. We’re not able to deep dive on the issue as we have reviewed the 3rd party documentation[3] that you are following, these projects and service accounts are configured via Terraform.

Please understand that Terraform is a third-party product not supported by Google, though we do support the underlying Google APIs that the Terraform Google Provider calls. Since these are Terraform-managed service accounts and resources, this is outside my scope of expertise and the assistance I can offer is limited. It is best to contact the proper support channels for the Terraform Google Provider and Terraform listed here [4] or much better if you can contact the contributors(i.e. @mohangmk) of the Github documentation[3] that you are following for better assistance. I have also found this link on how to contact the terraform support community[5] if you have further clarifications.

It is also not a best practice/approach to fix all the errors that we are getting from each of the projects as not all errors are really intended or related to the Android deployment problem that you are having. It is really best if we can contact the contributors of the 3rd party documentation that you are following for better assistance.

[1] "Permission monitoring.timeSeries.create denied (or the resource may not exist)." [2] serviceAccount:[REMOVED FOR PRIVACY]-apps.svc.id.goog[istio-system/promsd] [3] https://github.com/GoogleCloudPlatform/fda-mystudies/blob/master/deployment/README.md [4] https://cloud.google.com/docs/terraform?hl=en#get_terraform_support_for [5] https://discuss.hashicorp.com/c/terraform-core/27"

jaseva commented 1 year ago

@Shashank-btc, I believe my app errors are related to Monitoring having to be manually configured as per these instructions here (which I have not done yet):

https://github.com/GoogleCloudPlatform/fda-mystudies/issues/971

https://github.com/GoogleCloudPlatform/fda-mystudies/pull/4246/commits/639d2491a99dc731b42d01d75a8a778e9323b13b

https://github.com/GoogleCloudPlatform/fda-mystudies/pull/4246/commits/639d2491a99dc731b42d01d75a8a778e9323b13b#diff-1b7ef935396ff0d592e61e984c0c785a5139754a8d875d90b088cc61f96cf7bd

https://github.com/GoogleCloudPlatform/fda-mystudies/blob/master/documentation/monitoring.md

I believe the errors in my data project should be resolved once I configure the Android app properly, log in for the first time, and then my assumption is that the BigQuery database tables will be created resolving some of the errors. Have you been successful with your deployment? Is monitoring turned off for a reason (i.e. cost)?

jaseva commented 1 year ago

Good news, my issue is resolved with being able to log into the Android app. As suspected my configuration settings where incorrect for the APP_ID in the api.properties not matching the APP ID value in Study Builder for the associated app.

I learned that many of my associated errors in the apps project on GCP are related to monitoring not being configured.