google / android-fhir

The Android FHIR SDK is a set of Kotlin libraries for building offline-capable, mobile-first healthcare applications using the HL7® FHIR® standard on Android.
https://google.github.io/android-fhir/
Apache License 2.0
465 stars 245 forks source link

demo application doesn't start on windows #2470

Closed icrc-fdeniger closed 2 months ago

icrc-fdeniger commented 3 months ago

Describe the bug can't start the demo application on Windows 10 with java 17

Relevant log:

java.io.FileNotFoundException: C:\WINDOWS\sqlite-3.36.0-d1d580cc-94e1-44dd-976b-9d0203cd82d9-sqlitejdbc.dll.lck (Access is denied)
    at java.base/java.io.FileOutputStream.open0(Native Method)
    at java.base/java.io.FileOutputStream.open(FileOutputStream.java:298)
    at java.base/java.io.FileOutputStream.<init>(FileOutputStream.java:237)
    at java.base/java.io.FileOutputStream.<init>(FileOutputStream.java:187)
    at org.sqlite.SQLiteJDBCLoader.extractAndLoadLibraryFile(SQLiteJDBCLoader.java:210)

I managed to let it work by migrating to kspid("com.google.devtools.ksp").version("1.9.21-1.0.16"): https://github.com/google/android-fhir/compare/master...icrc-fdeniger:android-fhir:icrc-ok-pull-data?expand=1#diff-84cb3f8fc96e6909e77e32e7f45a90496814fd34fb2e9822056aea55aaa0e9e7

I believe the root is that I can open a file located the folder C:\WINDOWS ( not an admin)

MJ1998 commented 3 months ago

Thanks for raising this @icrc-fdeniger

I think I know why ksp works and kapt does not. The overhead of kapt's stub generation process likely ran into permission problems in your non-admin setup. The exact folders it tried to write to are unknown, but they were probably system-protected. Ksp, on the other hand, directly processes kotlin symbols removing the need for stub generation entirely, perhaps bypassing the troublesome permission issues.

See more in Why KSP? Also Android documentation recommends to migrate to ksp!

This seems to be a valid change and I think ksp is safe for room compiler. Would you like to submit a PR for this ?

icrc-fdeniger commented 3 months ago

Sure I tried with a first draft here :) https://github.com/google/android-fhir/pull/2471

Not an expert with KSP, KAPT so I'm sure it should be polished. it's ok for me with this configuration but I will need to have feedbacks on this. For instance for the ksp version (1.9.21-1.0.16). It seems it was the only config working for me.. but I can do more tests

MJ1998 commented 3 months ago

Thanks and no worries @icrc-fdeniger. Have left some comments on your PR.