You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 2def459
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: packages/pigeon/CHANGELOG.md
+5Lines changed: 5 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,3 +1,8 @@
1
+
## 29.0.12
2
+
3
+
*[kotlin] Warns after JNI code generation if the `jni` version constraint in `pubspec.yaml` allows versions below `1.1.1`.
4
+
* Updates `jni` dependency to `^1.1.1` and removes manual Kotlin keep rules from native interop guides and migration skill now that `package:jni` includes them.
5
+
1
6
## 29.0.11
2
7
3
8
*[swift] Warns after FFI code generation if the `objective_c` version constraint in `pubspec.yaml` does not match the generated `ObjCVersionCheck`.
Copy file name to clipboardExpand all lines: packages/pigeon/native_interop_guide.md
+1-32Lines changed: 1 addition & 32 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -36,7 +36,7 @@ Using Native Interop in pigeon follows the standard pigeon workflow, with a few
36
36
3.**Configure Options**: Configure `kotlinOptions.useJni` or `swiftOptions.useFfi` in your `PigeonOptions` (see [Step 2: Configure Pigeon Options](#step-2-configure-pigeon-options) below).
37
37
4.**Prerequisites**: Ensure your local environment meets the toolchain prerequisites for `jnigen` and `ffigen` (see [Section 3: Prerequisites](#3-prerequisites) below).
38
38
5.**Run Code Generation**: Run the `pigeon` tool to generate the native bridge code and interop bindings (see [Step 3: Run Code Generation](#step-3-run-code-generation) below).
39
-
6.**Configure Build Systems**: For Swift FFI, configure CocoaPods or Swift Package Manager (SwiftPM) to compile the intermediate Objective-C bridge files (see [Step 4: iOS/macOS Build System Configuration (FFI)](#step-4-iosmacos-build-system-configuration-ffi) below). For Kotlin JNI, add keep rules so that Android release builds work (see [Step 5: Android Release Build Configuration (JNI)](#step-5-android-release-build-configuration-jni) below). <!-- TODO(tarrinneal): Remove this JNI sentence once package:jni ships these keep rules: https://github.com/dart-lang/native/issues/3732 -->
39
+
6.**Configure Build Systems**: For Swift FFI, configure CocoaPods or Swift Package Manager (SwiftPM) to compile the intermediate Objective-C bridge files (see [Step 4: iOS/macOS Build System Configuration (FFI)](#step-4-iosmacos-build-system-configuration-ffi) below).
40
40
7.**Implement and Call**: Implement the generated protocol/class interface in your native codebase and call the generated Dart methods from your Flutter application.
41
41
42
42
---
@@ -201,36 +201,6 @@ When implementing Native Interop host APIs directly in an application target rat
201
201
```
202
202
Calling `register(api:)` in native code also prevents the Xcode linker (`-dead_strip`) from stripping the setup class from the compiled binary.
<!-- TODO(tarrinneal): Remove this section once package:jni ships these keep rules: https://github.com/dart-lang/native/issues/3732 -->
207
-
208
-
Flutter enables R8 for Android release builds by default. R8 removes, renames, and merges classes and members that it doesn't see being used. JNI looks up classes and members by name at runtime, so everything that JNI reaches must keep its original name.
209
-
210
-
Pigeon adds `@Keep` to every generated Kotlin class that the generated Dart code reaches through JNI, so the generated code needs no extra rules. However, `package:jni` and the generated Dart code also look up several Kotlin standard library classes by name to call Kotlin `suspend` functions (`@async` methods) and to implement them from Dart. Library classes can't be annotated, so until `package:jni` includes rules for these classes, you must add them yourself:
211
-
212
-
```text
213
-
# Kotlin classes that package:jni and the generated Dart code look up by name.
214
-
-keep class kotlin.Unit { *; }
215
-
-keep class kotlin.Result { *; }
216
-
-keep class kotlin.Result$Failure { *; }
217
-
-keep class kotlin.coroutines.Continuation { *; }
218
-
-keep class kotlin.coroutines.intrinsics.CoroutineSingletons { *; }
219
-
-keep class kotlin.coroutines.intrinsics.IntrinsicsKt { *; }
220
-
```
221
-
222
-
***Plugins**: Add the rules to a file in the plugin's `android/` directory, such as `consumer-rules.pro`, and list it in `consumerProguardFiles` in the plugin's `android/build.gradle` or `android/build.gradle.kts`. R8 then applies the rules to every application that uses the plugin:
223
-
```gradle
224
-
android {
225
-
defaultConfig {
226
-
consumerProguardFiles("consumer-rules.pro")
227
-
}
228
-
}
229
-
```
230
-
***Applications**: Add the rules to `android/app/proguard-rules.pro`. Flutter applies this file to release builds when it exists.
231
-
232
-
Debug and profile builds are not minified, so test a release build (for example, with `flutter run --release`) to verify the configuration.
233
-
234
204
---
235
205
236
206
## 5. Troubleshooting Automated Generation
@@ -299,7 +269,6 @@ If native interop calls work in debug builds but fail in release builds with `ja
299
269
-**Cause**: R8 removed or renamed a class or member that JNI looks up by name.
300
270
-**Solution**:
301
271
- If the error names a class generated by Pigeon, regenerate your Pigeon output with Pigeon 29.0.7 or later, which adds `@Keep` to every generated class that JNI reaches.
302
-
- If the error names a class in the `kotlin` package (for example, `kotlin/coroutines/Continuation` in the signature of a `suspend` method), add the keep rules from [Step 5](#step-5-android-release-build-configuration-jni). <!-- TODO(tarrinneal): Remove this bullet once package:jni ships these keep rules: https://github.com/dart-lang/native/issues/3732 -->
303
272
- To see what R8 removed or renamed, check `build/app/outputs/mapping/release/mapping.txt` in the application directory.
Copy file name to clipboardExpand all lines: packages/pigeon/native_interop_migration_guide.md
+1-23Lines changed: 1 addition & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -186,29 +186,7 @@ Ensure your build system is configured appropriately:
186
186
187
187
---
188
188
189
-
## 6. Android Release Build Configuration (JNI)
190
-
191
-
<!-- TODO(tarrinneal): Remove this section, and renumber the next one, once package:jni ships these keep rules: https://github.com/dart-lang/native/issues/3732 -->
192
-
193
-
Flutter enables R8 for Android release builds by default, and R8 removes or renames classes that JNI looks up by name. Pigeon adds `@Keep` to the generated Kotlin classes that JNI reaches, but `package:jni` and the generated Dart code also look up Kotlin standard library classes by name to call and implement `suspend` functions. Until `package:jni` includes rules for these classes, add them to a `consumer-rules.pro` file in your plugin's `android/` directory:
194
-
195
-
```text
196
-
# Kotlin classes that package:jni and the generated Dart code look up by name.
197
-
-keep class kotlin.Unit { *; }
198
-
-keep class kotlin.Result { *; }
199
-
-keep class kotlin.Result$Failure { *; }
200
-
-keep class kotlin.coroutines.Continuation { *; }
201
-
-keep class kotlin.coroutines.intrinsics.CoroutineSingletons { *; }
202
-
-keep class kotlin.coroutines.intrinsics.IntrinsicsKt { *; }
203
-
```
204
-
205
-
Then add `consumerProguardFiles("consumer-rules.pro")` to `android.defaultConfig` in the plugin's `android/build.gradle` or `android/build.gradle.kts`, so that every app using the plugin applies the rules. For a standalone application, add the rules to `android/app/proguard-rules.pro` instead.
206
-
207
-
Debug builds are not minified, so test a release build (for example, by running the example app with `flutter run --release`) after migrating. See [Step 5 of the Native Interop Guide](./native_interop_guide.md#step-5-android-release-build-configuration-jni) for details.
To use Native Interop and its external code generators:
214
192
-**`jnigen` 1.0.0 or later**: Earlier versions of JNIgen cannot parse metadata from newer Kotlin compilers and fail with `IllegalArgumentException: Provided Metadata instance has version ... while maximum supported version is ...`. `jnigen` 1.0.0 supports Kotlin metadata up to 2.4, and uses the JDK bundled with Flutter by default.
0 commit comments