Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running the app with amplify SDK V2.14.13 on Android OS version 7 and 7.1 devices immediately crashes. #2790

Closed
1 task done
cojobs opened this issue Apr 24, 2024 · 4 comments
Labels
core Amplify Core library question General question

Comments

@cojobs
Copy link

cojobs commented Apr 24, 2024

Before opening, please confirm:

Language and Async Model

Kotlin, Kotlin - Coroutines

Amplify Categories

Analytics

Gradle script dependencies

    api ("com.amplifyframework:aws-analytics-pinpoint:2.14.13") {
        exclude( group = "androidx.lifecycle", module = "lifecycle-viewmodel-ktx")
    }
    api ("com.amplifyframework:aws-auth-cognito:2.14.13") {
        exclude( group = "androidx.lifecycle", module = "lifecycle-viewmodel-ktx")
    }



Environment information

Build time:   2023-04-21 12:31:26 UTC
Revision:     1cf537a851c635c364a4214885f8b9798051175b

Kotlin:       1.8.10
Groovy:       3.0.15
Ant:          Apache Ant(TM) version 1.10.11 compiled on July 10 2021
JVM:          17.0.10 (JetBrains s.r.o. 17.0.10+0-17.0.10b1087.21-11572160)
OS:           Mac OS X 12.3 aarch64



Please include any relevant guides or documentation you're referencing

https://docs.amplify.aws/android/start/project-setup/prerequisites/

Describe the bug

Running the app with amplify SDK V2.14.13 on Android OS version 7 and 7.1 devices immediately crashes.

The documentation https://docs.amplify.aws/android/start/project-setup/prerequisites/ specifies android 7.0 or later.

Does the amplify SDK only support Android 8.0 and above, contrary to what the guide documentation says?
If not, could you please revise it to support from android 7.0 onwards?

(https://developer.android.com/reference/java/time/Duration says that the Duration class was added as of API level 26.)

Reproduction steps (if applicable)

  1. Run the app with the amplify SDK V2.14.13 on top of an android 7.0 or 7.1 device.
  2. It crashes immediately.

Code Snippet

Amplify.addPlugin(AWSCognitoAuthPlugin())

Log output

java.lang.NoClassDefFoundError: Failed resolution of: Ljava/time/Duration;
    	at aws.smithy.kotlin.runtime.http.engine.okhttp.OkHttpEngineKt.buildClient(OkHttpEngine.kt:88)
    	at aws.smithy.kotlin.runtime.http.engine.okhttp.OkHttpEngineKt.access$buildClient(OkHttpEngine.kt:1)
    	at aws.smithy.kotlin.runtime.http.engine.okhttp.OkHttpEngine.<init>(OkHttpEngine.kt:44)
    	at aws.smithy.kotlin.runtime.http.engine.okhttp.OkHttpEngine$Companion.invoke(OkHttpEngine.kt:38)
    	at aws.smithy.kotlin.runtime.http.engine.DefaultHttpEngineJVMKt.newDefaultHttpEngine(DefaultHttpEngineJVM.kt:14)
    	at aws.smithy.kotlin.runtime.http.engine.DefaultHttpEngineKt.DefaultHttpEngine(DefaultHttpEngine.kt:23)
    	at aws.smithy.kotlin.runtime.http.engine.HttpEngineConfigImpl$BuilderImpl$engineConstructor$1.invoke(HttpEngineConfigImpl.kt:20)
    	at aws.smithy.kotlin.runtime.http.engine.HttpEngineConfigImpl$BuilderImpl$engineConstructor$1.invoke(HttpEngineConfigImpl.kt:20)
    	at aws.smithy.kotlin.runtime.http.engine.HttpEngineConfigImpl$BuilderImpl$engineSupplier$1.invoke(HttpEngineConfigImpl.kt:21)
    	at aws.smithy.kotlin.runtime.http.engine.HttpEngineConfigImpl$BuilderImpl$engineSupplier$1.invoke(HttpEngineConfigImpl.kt:21)
    	at aws.smithy.kotlin.runtime.http.engine.HttpEngineConfigImpl$BuilderImpl.buildHttpEngineConfig(HttpEngineConfigImpl.kt:75)
    	at aws.sdk.kotlin.services.cognitoidentity.CognitoIdentityClient$Config$Builder.buildHttpEngineConfig(CognitoIdentityClient.kt)
    	at aws.sdk.kotlin.services.cognitoidentity.CognitoIdentityClient$Config.<init>(CognitoIdentityClient.kt:133)
    	at aws.sdk.kotlin.services.cognitoidentity.CognitoIdentityClient$Config.<init>(CognitoIdentityClient.kt)
    	at aws.sdk.kotlin.services.cognitoidentity.CognitoIdentityClient$Config$Builder.build(CognitoIdentityClient.kt:284)
    	at aws.sdk.kotlin.services.cognitoidentity.CognitoIdentityClient$Config$Builder.build(CognitoIdentityClient.kt:171)
    	at aws.smithy.kotlin.runtime.client.AbstractSdkClientBuilder.build(AbstractSdkClientBuilder.kt:20)
    	at aws.smithy.kotlin.runtime.client.AbstractSdkClientBuilder.build(AbstractSdkClientBuilder.kt:13)
    	at aws.smithy.kotlin.runtime.client.SdkClientFactory$DefaultImpls.invoke(SdkClientFactory.kt:32)
    	at aws.sdk.kotlin.runtime.config.AbstractAwsSdkClientFactory.invoke(AbstractAwsSdkClientFactory.kt:42)
    	at com.amplifyframework.auth.cognito.AWSCognitoAuthService$Companion.fromConfiguration$aws_auth_cognito_release(AWSCognitoAuthService.kt:53)
    	at com.amplifyframework.auth.cognito.AWSCognitoAuthPlugin.configure(AWSCognitoAuthPlugin.kt:133)
    	at com.amplifyframework.core.category.Category.configure(Category.java:92)
    	at com.amplifyframework.core.Amplify.configure(Amplify.java:159)
    	at com.amplifyframework.core.Amplify.configure(Amplify.java:129)

Caused by: java.lang.ClassNotFoundException: Didn't find class "java.time.Duration" on path: DexPathList[[zip file "/system/framework/android.test.runner.jar", zip file "/data/app/com.xxx.xxx.debug-1/base.apk"],nativeLibraryDirectories=[/data/app/com.xxx.xxx.debug-1/lib/arm64, /data/app/com.xxx.xxx.debug-1/base.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib64]]
    	at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
    	at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
    	at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
    	... 47 more

amplifyconfiguration.json

No response

GraphQL Schema

// Put your schema below this line

Additional information and screenshots

No response

@github-actions github-actions bot added the pending-triage Issue is pending triage label Apr 24, 2024
@mattcreaser mattcreaser added core Amplify Core library question General question labels Apr 24, 2024
@github-actions github-actions bot removed the pending-triage Issue is pending triage label Apr 24, 2024
@mattcreaser
Copy link
Member

Hi @cojobs. Amplify (and its dependencies) use Java 8 features, so if your minimum SDK is below 26 you need to enable core library desugaring for your app. This is covered in the install Amplify libraries section of the docs.

Here's an example:

// build.gradle.kts
android {
    compileOptions {
        isCoreLibraryDesugaringEnabled = true
    }
}

dependencies {
    coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.0.4")
}

This should resolve your issue. Please let us know if you have any other questions.

@mattcreaser mattcreaser added the pending-community-response Issue is pending response from the issue requestor label Apr 24, 2024
@cojobs
Copy link
Author

cojobs commented Apr 24, 2024

Thanks for the detailed answer, I'll give it a try!

@github-actions github-actions bot removed the pending-community-response Issue is pending response from the issue requestor label Apr 24, 2024
@mattcreaser
Copy link
Member

Great. I'll close this issue but please feel free to open a new one if necessary.

Copy link
Contributor

This issue is now closed. Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Amplify Core library question General question
Projects
None yet
Development

No branches or pull requests

2 participants