Repository navigation
Closed
Description
Jnigen fails with the following error.
This error message does not help me know what to do next.
What file does this error message mention about?
dart run jnigen --config .\jnigen.yaml
(jnigen) INFO: ApiSummarizer.jar exists. Skipping build..
(jnigen) INFO: execute java -jar .dart_tool/jnigen/ApiSummarizer.jar -c jar\okio-3.0.0.jar;jar\okhttp-4.10.0.jar --backend asm okhttp3.OkHttpClient
Unhandled exception:
FormatException: Unexpected extension byte (at offset 1)
#0 _Utf8Decoder.convertChunked (dart:convert-patch/convert_patch.dart:1852:7)
#1 _Utf8ConversionSink.addSlice (dart:convert/string_conversion.dart:304:28)
#2 _Utf8ConversionSink.add (dart:convert/string_conversion.dart:300:5)
#3 _ConverterStreamEventSink.add (dart:convert/chunked_conversion.dart:69:18)
#4 _SinkTransformerStreamSubscription._handleData (dart:async/stream_transformers.dart:111:24)
#5 _RootZone.runUnaryGuarded (dart:async/zone.dart:1594:10)
#6 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
#7 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
#8 _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:784:19)
#9 _StreamController._add (dart:async/stream_controller.dart:658:7)
#10 _StreamController.add (dart:async/stream_controller.dart:606:5)
#11 _Socket._onData (dart:io-patch/socket_patch.dart:2447:41)
#12 _RootZone.runUnaryGuarded (dart:async/zone.dart:1594:10)
#13 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
#14 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
#15 _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:784:19)
#16 _StreamController._add (dart:async/stream_controller.dart:658:7)
#17 _StreamController.add (dart:async/stream_controller.dart:606:5)
#18 new _RawSocket.<anonymous closure> (dart:io-patch/socket_patch.dart:1936:33)
#19 _NativeSocket.issueReadEvent.issue (dart:io-patch/socket_patch.dart:1379:14)
#20 _microtaskLoop (dart:async/schedule_microtask.dart:40:21)
#21 _startMicrotaskLoop (dart:async/schedule_microtask.dart:49:5)
#22 _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:118:13)
#23 _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:185:5)
Flutter (Channel stable, 3.16.4, on Microsoft Windows [Version 10.0.22631.2428], locale ja-JP)
• Flutter version 3.16.4 on channel stable at C:\flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 2e9cb0aa71 (3 weeks ago), 2023-12-11 14:35:13 -0700
• Engine revision 54a7145303
• Dart version 3.2.3
• DevTools version 2.28.4
dependencies:
jni: 0.7.2
dev_dependencies:
jnigen: 0.7.0Metadata
Metadata
Assignees
Type
Projects
- StatusShow more project fieldsDone
Activity
HosseinYousefi commentedon Jan 16, 2024
Can you share your
jnigen.yaml?glanium commentedon Jan 17, 2024
It's simple for test purpose.
marcoedomingos commentedon Jan 26, 2024
Hello @glanium, dont' know if you still facing this issue, but, from I can see from your config file, you trying to access a dependency that it is not implemented in the project, you need to fetch the dependency to be able to import it, like this:
Don't forget to run flutter build apk before generate the bindings, tell me if this help
HosseinYousefi commentedon Jan 26, 2024
I had assumed that the
.jarfiles do exist in thejar/directory. I tried running it on my machine and it "works", meaning that it produces the bindings, however sinceokhttpis a Kotlin library, there are functions likepublic final okhttp3.OkHttpClient$Builder -addNetworkInterceptor(kotlin.jvm.functions.Function1 function1)(with a hyphen in the name) which break the code, as having-in the identifiers is not allowed in Dart.This is done in okhttp to prevent ambiguous overloads from Java: https://github.com/square/okhttp/blob/76acdc5d0d437253d01dc4f90e43247d1ad22682/okhttp/src/main/kotlin/okhttp3/OkHttpClient.kt#L649-L664
The fix is to either exclude the generation of this method for now, or a patch to jnigen to convert
-in the name to something else. Unfortunately we don't yet support renaming. See #787.marcoedomingos commentedon Jan 26, 2024
@HosseinYousefi you managed to run without fetch the dependencies in the config file?
HosseinYousefi commentedon Jan 26, 2024
If you download the jars yourself, and put them in
jars/directory, you can generate bindings.maven_downloadsis a convenience tool which I proposed to be eventually removed #576.glanium commentedon Jan 26, 2024
I had downloaded jar files manually and put them in jars directory but dose not work with that error.
that error message does not help me at all.
Then I don't know what to do next.
HosseinYousefi commentedon Jan 26, 2024
It might be a windows problem, let me try it with that as well.
HosseinYousefi commentedon Jan 26, 2024
Are you sure that
lib/src/okhttp3.dartis not being generated? I downloaded the jar file from https://mvnrepository.com/artifact/com.squareup.okhttp3/okhttp/4.10.0 and with the exact same config yaml, it works on both mac and Windows.glanium commentedon Jan 26, 2024
umm.
I'm sure lib/src/okhttp3.dart is not generated.
glanium commentedon Jan 26, 2024
I've checked jar's contents by renaming to .zip.
It seems correct one.
okhttp-4.10.0.jar 807,357 bytes
okio-3.0.0.jar 24,754 bytes
glanium commentedon Jan 26, 2024
JAVA_HOME=C:\Program Files\Microsoft\jdk-11.0.16.101-hotspot
marcoedomingos commentedon Jan 29, 2024
About that, what do you think about this proposal #956?
1 remaining item
glanium commentedon Apr 8, 2024
yes.
i got same error with jni 0.8.0 and jnigen 0.8.0
HosseinYousefi commentedon Apr 8, 2024
I'll try to fix this issue for the next version then. Could you please create a small reproducible example repository that fails?
HosseinYousefi commentedon Apr 23, 2024
@glanium
java(JDK) are you using?java -jar .dart_tool/jnigen/ApiSummarizer.jar -c jar\okio-3.0.0.jar;jar\okhttp-4.10.0.jar --backend asm okhttp3.OkHttpClient?glanium commentedon Apr 24, 2024
oh, this might be cause.
HosseinYousefi commentedon Apr 24, 2024
That's odd, it seems that the
okhttp3.OkHttpClientis not being parsed as an argument in your machine, causinggetArgs().lengthto be< 1! Again everything seems to be working on my machine on the same OpenJDK version. The only thing that might cause this issue which is different in my setup is yourja-JPlocale. So this is most likely an issue in Apache Commons CLI and/or Windows terminal. I'll investigate this further.Edit: yes, I can reproduce the issue with
ja-JPlocale.P.S. I assume
..dart_toolwith two dots is a typo, otherwise it wouldn't have run at all?[jnigen] Close #877; Fix summarizer and improve errors
[jnigen] Fix summarizer and improve errors (#1103)
Squashed commit of the following: