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
244 stars 114 forks source link

IllegalStateException: Expected Android API level 21+ but was 19 #1918

Closed atomicalsoftwares closed 1 year ago

atomicalsoftwares commented 2 years ago

Before opening, please confirm:

Language and Async Model

Java

Amplify Categories

DataStore

Gradle script dependencies

```groovy implementation 'com.amplifyframework:aws-auth-cognito:1.37.2' implementation 'com.amplifyframework:core:1.37.2' implementation 'com.amplifyframework:aws-api:1.37.2' implementation 'com.amplifyframework:aws-datastore:1.37.2' implementation 'com.clover.sdk:clover-android-sdk:288' implementation 'com.github.delight-im:Android-AdvancedWebView:v3.2.1' implementation ("com.squareup.okhttp3:okhttp:4.9.1") ```

Environment information

``` Android Plugin: 4.1.3 Gradle Version: 6.5 ```

Please include any relevant guides or documentation you're referencing

No response

Describe the bug

Application targets API 25 with minimum API supported 17. OK HTTP Library has a minimum API of 21. When you attempt to run on anything lower, the error below occurs. You cannot downgrade or force a lower version of okhttp (say 3.12) because Datastore will fail. Although the logs indicate that the requests completed successfully, nothing ever sync to Amplify Cloud. (on okhttp 3.12)

Reproduction steps (if applicable)

  1. Setup basic app with Datastore enabled
  2. Enable Cloud Sync
  3. Use the latest libraries for amplify
  4. Run a sample TODO file with a very basic schema and attempt to sync to cloud
  5. Android app logs will say success full (in the event of okhttp 3.12) but if you're on the latest okhttp it will crash the app if you're running lower than API 21.

Code Snippet

// Put your code below this line.

Log output

``` 0java.lang.ExceptionInInitializerError -- 1 at okhttp3.internal.platform.Platform$Companion.findAndroidPlatform(Platform.kt:219) 2 at okhttp3.internal.platform.Platform$Companion.findPlatform(Platform.kt:212) 3 at okhttp3.internal.platform.Platform$Companion.access$findPlatform(Platform.kt:169) 4 at okhttp3.internal.platform.Platform.<clinit>(Platform.kt:170) 5 at okhttp3.OkHttpClient.<init>(OkHttpClient.kt:237) 6 at okhttp3.OkHttpClient$Builder.build(OkHttpClient.kt:1069) 7 at com.amplifyframework.api.aws.SubscriptionEndpoint.<init>(SubscriptionEndpoint.java:91) 8 at com.amplifyframework.api.aws.AWSApiPlugin.configure(AWSApiPlugin.java:177) 9 at com.amplifyframework.core.category.Category.configure(Category.java:91) 10 at com.amplifyframework.core.Amplify.configure(Amplify.java:156) 11 at com.atomicalsoftwares.integracionathmovil.MainActivity$2.onResult(MainActivity.java:306) 12 at com.atomicalsoftwares.integracionathmovil.MainActivity$2.onResult(MainActivity.java:294) 13 at com.amazonaws.mobile.client.internal.InternalCallback.call(InternalCallback.java:75) 14 at com.amazonaws.mobile.client.internal.InternalCallback.onResult(InternalCallback.java:62) 15 at com.amazonaws.mobile.client.AWSMobileClient$11.run(AWSMobileClient.java:1896) 16 at com.amazonaws.mobile.client.internal.InternalCallback$1.run(InternalCallback.java:101) 17 at java.lang.Thread.run(Thread.java:841) 18Caused by: java.lang.IllegalStateException: Expected Android API level 21+ but was 19 19 at okhttp3.internal.platform.AndroidPlatform.<clinit>(AndroidPlatform.kt:153) 20 ... 17 more ```

amplifyconfiguration.json

No response

GraphQL Schema

```graphql SCHEMA independent, use any basic schema. ```

Additional information and screenshots

No response

chrisbonifacio commented 1 year ago

Hi @atomicalsoftwares 👋 thanks for raising this issue. Could you explain a bit what your use case is for using a version lower than 21?

atomicalsoftwares commented 1 year ago

Hello!

I develop apps for a Point of Sale system and my merchant base has Devices (60%+) (couple of thousands) that use these that they're API 19 or 17. Because of the amount of devices, their cost and they're actively being supported is close to imposible to exclude them from the user base.

Thanks for getting back!

gpanshu commented 1 year ago

Hi @atomicalsoftwares in order to be able to re-build our entire library we had to jump to a higher version. We are internally discussing lowering the version down but it will still not be 19. You can still use V1 of the library until the version bump and use the escape hatch for any advanced needs but in order for you to use our V2 version you will need to version bump your app and thus your devices.

github-actions[bot] commented 1 year ago

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.