Skip to content

Commit

Permalink
[ok_http]: Use the Android SDK to generate JNI bindings. (#1229)
Browse files Browse the repository at this point in the history
  • Loading branch information
Anikate-De committed Jun 10, 2024
1 parent b522000 commit 93ff4a9
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.
3 changes: 0 additions & 3 deletions pkgs/ok_http/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,3 @@ migrate_working_dir/
**/doc/api/
.dart_tool/
build/

# Ignore the JAR files required to generate JNI Bindings
jar/
3 changes: 3 additions & 0 deletions pkgs/ok_http/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ group = "com.example.ok_http"
version = "1.0"

buildscript {
// Required to support `okhttp:4.12.0`.
ext.kotlin_version = '1.9.23'
repositories {
google()
mavenCentral()
Expand All @@ -12,6 +14,7 @@ buildscript {
dependencies {
// The Android Gradle Plugin knows how to build native code with the NDK.
classpath("com.android.tools.build:gradle:7.3.0")
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}

Expand Down
7 changes: 7 additions & 0 deletions pkgs/ok_http/example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,10 @@ android {
flutter {
source = "../.."
}

dependencies {
// "com.squareup.okhttp3:okhttp:4.12.0" is only present so that
// `jnigen` will work. Applications should not include this line.
// The version should be synced with `pkgs/ok_http/android/build.gradle`.
implementation('com.squareup.okhttp3:okhttp:4.12.0')
}
12 changes: 5 additions & 7 deletions pkgs/ok_http/jnigen.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
# To regenerate the JNI Bindings, download the OkHttp 4.12.0 JAR file from the Maven Repository
# and place them in 'jar/'.
# https://mvnrepository.com/artifact/com.squareup.okhttp3/okhttp/4.12.0
# Then run the command: dart run jnigen --config jnigen.yaml
# Regenerate the JNI Bindings using: dart run jnigen --config jnigen.yaml

summarizer:
backend: asm
Expand All @@ -11,6 +8,10 @@ output:
path: "lib/src/jni/bindings.dart"
structure: single_file

android_sdk_config:
add_gradle_deps: true
android_example: "example/"

enable_experiment:
- "interface_implementation"

Expand Down Expand Up @@ -81,6 +82,3 @@ exclude:
- "okhttp3.Headers#-deprecated_size"
- "okhttp3.Dispatcher#-deprecated_executorService"
- "okhttp3.Cache#-deprecated_directory"

class_path:
- "jar/okhttp-4.12.0.jar"

0 comments on commit 93ff4a9

Please sign in to comment.