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
483 stars 283 forks source link

[Apple Silicon] Cannot connect to SQLite datasource on M1 #914

Closed f-odhiambo closed 2 years ago

f-odhiambo commented 2 years ago

Describe the bug Issues around SQLite loaders while trying to run apps on M1 based macs. No native library to support

Component Reference app or SDC gallery app

To Reproduce Steps to reproduce the behaviour:

  1. Try to build and run the Android FHIR SDK sample apps on M1 silicon
  2. See error
Error opening connection
No native library is found for os.name=Mac and os.arch=aarch64. path=/org/sqlite/native/Mac/aarch64.

Caused by: java.lang.Exception: No native library is found for os.name=Mac and os.arch=aarch64. path=/org/sqlite/native/Mac/aarch64
    at org.sqlite.SQLiteJDBCLoader.loadSQLiteNativeLibrary(SQLiteJDBCLoader.java:333)
    at org.sqlite.SQLiteJDBCLoader.initialize(SQLiteJDBCLoader.java:64)
    at androidx.room.verifier.DatabaseVerifier.<clinit>(DatabaseVerifier.kt:71)

Suggested behavior

Open build.gradle.kts in engine Add kapt("org.xerial:sqlite-jdbc:3.34.0") Before kapt(Dependencies.Room.compiler)

Expected behaviour The application should build normally similar to intel based macs

Screenshots N/A

Smartphone (please complete the following information): Try running on Emulator or Physcicsla device API 25 and above

Additional context Add any other context about the problem here. See more here https://youtrack.jetbrains.com/issue/DBE-12342 Would you like to work on the issue? N/A

jingtang10 commented 2 years ago

are you still experiencing this issue?

i'm not sure if apple silicon or m1 is the issue. it's probably more likely the android sdk in android studio. can you please share your gradle jdk setup and the project structure set up in android studio?

f-odhiambo commented 2 years ago

I think I got a solution to this

Add

  kapt ("org.xerial:sqlite-jdbc:3.36.0.3")
  implementation("org.robolectric:robolectric:4.7.3")

Before kapt(Dependencies.Room.compiler)

in the build.gradle.kts (Module: android-fhir.engine)

Research links here

  1. https://github.com/robolectric/robolectric/issues/6311
  2. https://issues.sonatype.org/browse/OSSRH-66040
  3. https://github.com/robolectric/robolectric/pull/6324
  4. https://github.com/xerial/sqlite-jdbc
  5. https://search.maven.org/artifact/io.github.ganadist.sqlite4java/libsqlite4java-osx-arm64/1.0.392/dylib
  6. https://issuetracker.google.com/issues/174695268?pli=1#comment10

Not sure how this can be fixed on SDK seems like an arm architecture issue with SQLIte support /Java libs CC @jingtang10

f-odhiambo commented 2 years ago

CC @Tarun-Bhardwaj

epicadk commented 2 years ago

@f-odhiambo room 2.4.0 solves this issue according the the release notes. See 2.4.0-alpha03 https://developer.android.com/jetpack/androidx/releases/room#version_240_2

Tarun-Bhardwaj commented 2 years ago

@f-odhiambo , can this issue be closed based on the comments above?

f-odhiambo commented 2 years ago

yes