Skip to content

Commit 93ff4a9

Browse files
authored
[ok_http]: Use the Android SDK to generate JNI bindings. (#1229)
1 parent b522000 commit 93ff4a9

File tree

4 files changed

+15
-10
lines changed

4 files changed

+15
-10
lines changed

pkgs/ok_http/.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,3 @@ migrate_working_dir/
2727
**/doc/api/
2828
.dart_tool/
2929
build/
30-
31-
# Ignore the JAR files required to generate JNI Bindings
32-
jar/

pkgs/ok_http/android/build.gradle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ group = "com.example.ok_http"
44
version = "1.0"
55

66
buildscript {
7+
// Required to support `okhttp:4.12.0`.
8+
ext.kotlin_version = '1.9.23'
79
repositories {
810
google()
911
mavenCentral()
@@ -12,6 +14,7 @@ buildscript {
1214
dependencies {
1315
// The Android Gradle Plugin knows how to build native code with the NDK.
1416
classpath("com.android.tools.build:gradle:7.3.0")
17+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
1518
}
1619
}
1720

pkgs/ok_http/example/android/app/build.gradle

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,10 @@ android {
5656
flutter {
5757
source = "../.."
5858
}
59+
60+
dependencies {
61+
// "com.squareup.okhttp3:okhttp:4.12.0" is only present so that
62+
// `jnigen` will work. Applications should not include this line.
63+
// The version should be synced with `pkgs/ok_http/android/build.gradle`.
64+
implementation('com.squareup.okhttp3:okhttp:4.12.0')
65+
}

pkgs/ok_http/jnigen.yaml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
# To regenerate the JNI Bindings, download the OkHttp 4.12.0 JAR file from the Maven Repository
2-
# and place them in 'jar/'.
3-
# https://mvnrepository.com/artifact/com.squareup.okhttp3/okhttp/4.12.0
4-
# Then run the command: dart run jnigen --config jnigen.yaml
1+
# Regenerate the JNI Bindings using: dart run jnigen --config jnigen.yaml
52

63
summarizer:
74
backend: asm
@@ -11,6 +8,10 @@ output:
118
path: "lib/src/jni/bindings.dart"
129
structure: single_file
1310

11+
android_sdk_config:
12+
add_gradle_deps: true
13+
android_example: "example/"
14+
1415
enable_experiment:
1516
- "interface_implementation"
1617

@@ -81,6 +82,3 @@ exclude:
8182
- "okhttp3.Headers#-deprecated_size"
8283
- "okhttp3.Dispatcher#-deprecated_executorService"
8384
- "okhttp3.Cache#-deprecated_directory"
84-
85-
class_path:
86-
- "jar/okhttp-4.12.0.jar"

0 commit comments

Comments
 (0)