aws-amplify / amplify-android

The fastest and easiest way to use AWS from your Android app.
https://docs.amplify.aws/lib/q/platform/android/
Apache License 2.0
249 stars 117 forks source link

Cloudwatch throws UnsatisfiedLinkError when loading sqlcipher library on Android 15 device using 16KB memory page sizes #2917

Open cHunter791 opened 2 months ago

cHunter791 commented 2 months ago

Before opening, please confirm:

Language and Async Model

Kotlin

Amplify Categories

Not applicable

Gradle script dependencies

```groovy implementation "com.amplifyframework:core-kotlin:2.21.1" implementation "com.amplifyframework:aws-auth-cognito:2.21.1" implementation "com.amplifyframework:aws-logging-cloudwatch:2.21.1" ```

Environment information

``` ------------------------------------------------------------ Gradle 8.7 ------------------------------------------------------------ Build time: 2024-03-22 15:52:46 UTC Revision: 650af14d7653aa949fce5e886e685efc9cf97c10 Kotlin: 1.9.22 Groovy: 3.0.17 Ant: Apache Ant(TM) version 1.10.13 compiled on January 4 2023 JVM: 17.0.10 (Homebrew 17.0.10+0) OS: Mac OS X 14.3 aarch64 ```

Please include any relevant guides or documentation you're referencing

https://developer.android.com/guide/practices/page-sizes

Describe the bug

We are testing our app on the new Android 15 SDK. As part of this investigation we are testing the app on an emulator that usings 16KB memory page sizes that Android 15 will now support in new devices (refer to above documentation)

When the app starts, it immediately crashes. The stacktrace is pointing to the Cloudwatch library as the source of the crash when it attempts to load the sqlcipher library.

java.lang.UnsatisfiedLinkError: dlopen failed: empty/missing DT_HASH/DT_GNU_HASH in "/data/app/~~dtJqMT5Wdr7uvd_u4kYHCA==/com.my.app-hpvblSBKxaJ32rafyO5VUw==/lib/arm64/libsqlcipher.so" (new hash type from the future?)
    at java.lang.Runtime.loadLibrary0(Runtime.java:1081)
    at java.lang.Runtime.loadLibrary0(Runtime.java:1003)
    at java.lang.System.loadLibrary(System.java:1765)
    at com.amplifyframework.logging.cloudwatch.db.CloudWatchLoggingDatabase$database$2.invoke(CloudWatchLoggingDatabase.kt:46)
    at com.amplifyframework.logging.cloudwatch.db.CloudWatchLoggingDatabase$database$2.invoke(CloudWatchLoggingDatabase.kt:45)
    at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
    at com.amplifyframework.logging.cloudwatch.db.CloudWatchLoggingDatabase.getDatabase(CloudWatchLoggingDatabase.kt:45)
    at com.amplifyframework.logging.cloudwatch.db.CloudWatchLoggingDatabase.query(CloudWatchLoggingDatabase.kt:127)
    at com.amplifyframework.logging.cloudwatch.db.CloudWatchLoggingDatabase.access$query(CloudWatchLoggingDatabase.kt:31)
    at com.amplifyframework.logging.cloudwatch.db.CloudWatchLoggingDatabase$queryAllEvents$2.invokeSuspend(CloudWatchLoggingDatabase.kt:69)
    at com.amplifyframework.logging.cloudwatch.db.CloudWatchLoggingDatabase$queryAllEvents$2.invoke(Unknown Source:14)
    at com.amplifyframework.logging.cloudwatch.db.CloudWatchLoggingDatabase$queryAllEvents$2.invoke(Unknown Source:12)
    at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturn(Undispatched.kt:61)
    at kotlinx.coroutines.BuildersKt__Builders_commonKt.withContext(Builders.common.kt:163)
    at kotlinx.coroutines.BuildersKt.withContext(Unknown Source:1)
    at com.amplifyframework.logging.cloudwatch.db.CloudWatchLoggingDatabase.queryAllEvents$aws_logging_cloudwatch_release(CloudWatchLoggingDatabase.kt:67)
    at com.amplifyframework.logging.cloudwatch.CloudWatchLogManager$syncLogEventsWithCloudwatch$2.invokeSuspend(CloudWatchLogManager.kt:116)
    at com.amplifyframework.logging.cloudwatch.CloudWatchLogManager$syncLogEventsWithCloudwatch$2.invoke(Unknown Source:14)
    at com.amplifyframework.logging.cloudwatch.CloudWatchLogManager$syncLogEventsWithCloudwatch$2.invoke(Unknown Source:12)
    at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturn(Undispatched.kt:61)
    at kotlinx.coroutines.BuildersKt__Builders_commonKt.withContext(Builders.common.kt:163)
    at kotlinx.coroutines.BuildersKt.withContext(Unknown Source:1)
    at com.amplifyframework.logging.cloudwatch.CloudWatchLogManager.syncLogEventsWithCloudwatch$aws_logging_cloudwatch_release(CloudWatchLogManager.kt:110)
    at com.amplifyframework.logging.cloudwatch.CloudWatchLogManager$onSignIn$1.invokeSuspend(CloudWatchLogManager.kt:222)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
    at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:104)
    at kotlinx.coroutines.internal.LimitedDispatcher$Worker.run(LimitedDispatcher.kt:111)
    at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:99)
    at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:585)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:802)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:706)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:693)

Checking the Cloudwatch plugin you are using the android-database-sqlcipher library, this has since been deprecated in favour of the sqlcipher-android library. The most recent release. 4.6.1, of sqlcipher-android has support for 16KB page sizes

Reproduction steps (if applicable)

  1. Create a new Android application
  2. Follow setup for adding Cloudwatch logging to the app here
  3. Setup an emulator following the instructions here to have it running Android 15 and using 16KB page sizes
  4. Run the app on the Android 15 emulator with 16KB page sizes, the app will immediately crash
  5. If you remove the Amplify.addPlugin(AWSCloudWatchLoggingPlugin()) line and run the app again, the app will not crash

Code Snippet

// Put your code below this line.

Log output

``` // Put your logs below this line ```

amplifyconfiguration.json

No response

GraphQL Schema

```graphql // Put your schema below this line ```

Additional information and screenshots

No response

tylerjroach commented 2 months ago

Thank you for the report! We will take this work on to provide 16kb page size support. We will update this ticket once support is ready.

tylerjroach commented 2 months ago

Effort to support 16KB page size can be found here: https://github.com/aws-amplify/amplify-android/pull/2919