From 601e067dea5cd27ac647e450ca7cb998e4d147b5 Mon Sep 17 00:00:00 2001 From: Anikate-De Date: Thu, 6 Jun 2024 02:09:12 +0530 Subject: [PATCH 1/3] pkgs/ok_http: use the android sdk to generate jni bindings --- pkgs/ok_http/.gitignore | 3 --- pkgs/ok_http/android/build.gradle | 12 ++++++++++++ pkgs/ok_http/example/android/app/build.gradle | 7 +++++++ pkgs/ok_http/jnigen.yaml | 12 +++++------- 4 files changed, 24 insertions(+), 10 deletions(-) diff --git a/pkgs/ok_http/.gitignore b/pkgs/ok_http/.gitignore index 2e58cc573d..ac5aa9893e 100644 --- a/pkgs/ok_http/.gitignore +++ b/pkgs/ok_http/.gitignore @@ -27,6 +27,3 @@ migrate_working_dir/ **/doc/api/ .dart_tool/ build/ - -# Ignore the JAR files required to generate JNI Bindings -jar/ diff --git a/pkgs/ok_http/android/build.gradle b/pkgs/ok_http/android/build.gradle index c21dab37b0..b5b42d5ff3 100644 --- a/pkgs/ok_http/android/build.gradle +++ b/pkgs/ok_http/android/build.gradle @@ -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() @@ -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" } } @@ -23,12 +26,21 @@ rootProject.allprojects { } apply plugin: "com.android.library" +apply plugin: 'kotlin-android' android { if (project.android.hasProperty("namespace")) { namespace = "com.example.ok_http" } + kotlinOptions { + jvmTarget = '1.8' + } + + sourceSets { + main.java.srcDirs += 'src/main/kotlin' + } + // Bumping the plugin compileSdk version requires all clients of this plugin // to bump the version in their app. compileSdk = 34 diff --git a/pkgs/ok_http/example/android/app/build.gradle b/pkgs/ok_http/example/android/app/build.gradle index 77ac8ef7fd..079240e25c 100644 --- a/pkgs/ok_http/example/android/app/build.gradle +++ b/pkgs/ok_http/example/android/app/build.gradle @@ -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') +} \ No newline at end of file diff --git a/pkgs/ok_http/jnigen.yaml b/pkgs/ok_http/jnigen.yaml index 1d0d60d457..fbb5bdf776 100644 --- a/pkgs/ok_http/jnigen.yaml +++ b/pkgs/ok_http/jnigen.yaml @@ -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 @@ -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" @@ -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" From f476f4cff7fde914348cbfc8e70d8f8dae9dd985 Mon Sep 17 00:00:00 2001 From: Anikate-De Date: Thu, 6 Jun 2024 02:11:51 +0530 Subject: [PATCH 2/3] fixed missing line at eof and comment periods --- pkgs/ok_http/android/build.gradle | 2 +- pkgs/ok_http/example/android/app/build.gradle | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/ok_http/android/build.gradle b/pkgs/ok_http/android/build.gradle index b5b42d5ff3..103ef35022 100644 --- a/pkgs/ok_http/android/build.gradle +++ b/pkgs/ok_http/android/build.gradle @@ -4,7 +4,7 @@ group = "com.example.ok_http" version = "1.0" buildscript { - // Required to support `okhttp:4.12.0` + // Required to support `okhttp:4.12.0`. ext.kotlin_version = '1.9.23' repositories { google() diff --git a/pkgs/ok_http/example/android/app/build.gradle b/pkgs/ok_http/example/android/app/build.gradle index 079240e25c..b5f9467b2f 100644 --- a/pkgs/ok_http/example/android/app/build.gradle +++ b/pkgs/ok_http/example/android/app/build.gradle @@ -62,4 +62,4 @@ dependencies { // `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') -} \ No newline at end of file +} From 1b9e1a353de09f0433cc528235fa3142b07ce859 Mon Sep 17 00:00:00 2001 From: Anikate-De Date: Sun, 9 Jun 2024 00:44:31 +0530 Subject: [PATCH 3/3] pkgs/ok_http: remove kotlin source inclusions for android sdk --- pkgs/ok_http/android/build.gradle | 9 --------- 1 file changed, 9 deletions(-) diff --git a/pkgs/ok_http/android/build.gradle b/pkgs/ok_http/android/build.gradle index 103ef35022..ea25148737 100644 --- a/pkgs/ok_http/android/build.gradle +++ b/pkgs/ok_http/android/build.gradle @@ -26,21 +26,12 @@ rootProject.allprojects { } apply plugin: "com.android.library" -apply plugin: 'kotlin-android' android { if (project.android.hasProperty("namespace")) { namespace = "com.example.ok_http" } - kotlinOptions { - jvmTarget = '1.8' - } - - sourceSets { - main.java.srcDirs += 'src/main/kotlin' - } - // Bumping the plugin compileSdk version requires all clients of this plugin // to bump the version in their app. compileSdk = 34