amplify-android icon indicating copy to clipboard operation
amplify-android copied to clipboard

Usage of API 24+ API in DataStore crashes App when running on API 22 while minSdkVersion saying API 16 is required

Open HuiSF opened this issue 3 years ago • 0 comments

Before opening, please confirm:

Language and Async Model

Java

Amplify Categories

DataStore

Gradle script dependencies

// Put output below this line


Environment information

# Put output below this line


Please include any relevant guides or documentation you're referencing

No response

Describe the bug

In gradle.build the minSdkVersion is defined as 16, meaning API 16 is require to run the App built with amplify-android.

https://github.com/aws-amplify/amplify-android/blob/880a182814514f9bce2c914ced44756f8af52f40/build.gradle#L56-L58

However, usage of API provided by API 24+ exists in the codebase, e.g.

https://github.com/aws-amplify/amplify-android/blob/880a182814514f9bce2c914ced44756f8af52f40/aws-datastore/src/main/java/com/amplifyframework/datastore/syncengine/SyncProcessor.java#L248-L250

The AtomicReference#accumulateAndGet was added in API 24.

And when developer tries to deploy App and run, e.g. on API 22, App crashes.

Fatal Exception: java.lang.NoClassDefFoundError: com.amplifyframework.datastore.syncengine.SyncProcessor$$ExternalSyntheticLambda13
       at com.amplifyframework.datastore.syncengine.SyncProcessor.lambda$syncModel$13(SyncProcessor.java:249)
       at com.amplifyframework.datastore.syncengine.SyncProcessor.$r8$lambda$2cJLxw0MiDnoj5SD1yHgXEAXleg(SyncProcessor.java)
       at com.amplifyframework.datastore.syncengine.SubscriptionProcessor$$InternalSyntheticLambda$0$dad4a5859176b69f01dda9628153ddd3768e4a48c8c9943a26aea231e4ca30ff$3.test$bridge(SubscriptionProcessor.java)
       at io.reactivex.rxjava3.internal.operators.flowable.FlowableTakeUntilPredicate$InnerSubscriber.onNext(FlowableTakeUntilPredicate.java:60)
       at io.reactivex.rxjava3.internal.operators.flowable.FlowableMap$MapSubscriber.onNext(FlowableMap.java:69)
       at io.reactivex.rxjava3.internal.operators.flowable.FlowableDoOnEach$DoOnEachSubscriber.onNext(FlowableDoOnEach.java:92)
       at io.reactivex.rxjava3.internal.util.HalfSerializer.onNext(HalfSerializer.java:45)

The minSdkVersion should reflect the actual required API level.

Reproduction steps (if applicable)

No response

Code Snippet

// Put your code below this line.

Log output

// Put your logs below this line


amplifyconfiguration.json

No response

GraphQL Schema

// Put your schema below this line


Additional information and screenshots

No response

HuiSF avatar Apr 05 '22 00:04 HuiSF