Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ok_http]: Use the Android SDK to generate JNI bindings. #1229

Merged
merged 3 commits into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"