Skip to content

Commit 9362fa1

Browse files
authored
misc: add documentation for OkHttp4Engine when using Android with R8 / ProGuard (#1340)
1 parent b5d177c commit 9362fa1

File tree

2 files changed

+24
-11
lines changed

2 files changed

+24
-11
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"id": "3ba693b2-e45f-4343-bd4e-883ab42acfe7",
3+
"type": "misc",
4+
"description": "Add documentation for OkHttp4Engine when using Android with R8 / ProGuard",
5+
"issues": [
6+
"https://github.com/smithy-lang/smithy-kotlin/issues/1339"
7+
]
8+
}

runtime/protocol/http-client-engines/http-client-engine-okhttp4/README.md

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,13 @@
11
# OkHttp4 Engine
22

3-
The AWS SDK for Kotlin depends on OkHttp **5.0.0-alpha.x**, which despite being in alpha, is claimed to be production stable and safe for consumption:
3+
The AWS SDK for Kotlin depends on a stable version of OkHttp **5.x**.
44

5-
> Although this release is labeled alpha, the only unstable thing in it is our new APIs.
6-
> This release has many critical bug fixes and is safe to run in production.
7-
> We’re eager to stabilize our new APIs so we can get out of alpha.
8-
>
9-
> https://square.github.io/okhttp/changelogs/changelog/#version-500-alpha12
10-
11-
This `OkHttp4Engine` is intended to be used for applications which still depend on okhttp3 **4.x** and can't upgrade to the newest alpha version.
5+
This `OkHttp4Engine` is intended to be used by applications which still depend on okhttp3 **4.x** and can't upgrade to the next major version.
126

137
## Configuration
148

159
### Gradle
16-
Because the SDK's default HTTP engine depends on okhttp3 **5.0.0-alpha.X**, consumers will need to force Gradle to resolve to **4.x** to prevent the alpha dependency from being introduced transitively. Here is a sample configuration:
10+
Because the SDK's default HTTP engine depends on okhttp3 **5.x**, consumers will need to force Gradle to resolve to **4.x** to prevent the newer dependency from being introduced transitively. Here is a sample configuration:
1711
```kts
1812
dependencies {
1913
implementation("aws.sdk.kotlin:s3:$SDK_VERSION") // and any other AWS SDK clients...
@@ -25,7 +19,7 @@ configurations.all {
2519
// Force resolve to OkHttp 4.x
2620
force("com.squareup.okhttp3:okhttp:4.12.0") // or whichever version you are using...
2721
}
28-
exclude(group = "com.squareup.okhttp3", module = "okhttp-coroutines") // Exclude dependency on okhttp-coroutines, which is introduced in 5.0.0-alpha.X
22+
exclude(group = "com.squareup.okhttp3", module = "okhttp-coroutines") // Exclude dependency on okhttp-coroutines, which was introduced in 5.0.0-alpha.X
2923
}
3024
```
3125

@@ -88,4 +82,15 @@ Caused by: java.lang.ClassNotFoundException: okhttp3.coroutines.ExecuteAsyncKt
8882

8983
It likely means you failed to configure the SDK client to use the `OkHttpEngine4`.
9084
Please double-check all of your SDK client configurations to ensure `httpClient = OkHttpEngine4()` is configured,
91-
and if the problem persists, [open an issue](https://github.com/smithy-lang/smithy-kotlin/issues/new/choose).
85+
and if the problem persists, [open an issue](https://github.com/smithy-lang/smithy-kotlin/issues/new/choose).
86+
87+
### Android R8 / ProGuard Configuration
88+
If you're using the OkHttp4Engine in an Android application with R8 or Proguard for code minification, and you see an error similar to the following:
89+
```
90+
ERROR: R8: Missing class okhttp3.coroutines.ExecuteAsyncKt (referenced from: java.lang.Object aws.smithy.kotlin.runtime.http.engine.okhttp.OkHttpEngine.roundTrip(aws.smithy.kotlin.runtime.operation.ExecutionContext, aws.smithy.kotlin.runtime.http.request.HttpRequest, kotlin.coroutines.Continuation))
91+
```
92+
93+
You'll need to add the following rule to either `proguard-rules.pro` or `consumer-rules.pro`, depending on your project structure:
94+
```
95+
-dontwarn okhttp3.coroutines.ExecuteAsyncKt
96+
```

0 commit comments

Comments
 (0)