This is not an error or anything, but I want to share the hiccup I had because otherwise some people might give up early.
Quick solution for busy people - need to run "flutter run" first for the example.
... and the background is following.
First cargo run - error: build failed
cargo run
Compiling nativeshell_examples v0.1.0 (/home/bus710/repo/examples)
Compiling glib v0.14.8
Compiling gio-sys v0.14.0
Compiling pango-sys v0.14.0
Compiling atk-sys v0.14.0
Compiling nativeshell v0.1.11
error: failed to run custom build command for `nativeshell_examples v0.1.0 (/home/bus710/repo/examples)`
Caused by:
process didn't exit successfully: /home/bus710/repo/examples/target/debug/build/nativeshell_examples-d760aadebf0231c2/build-script-build
(exit status: 101)
--- stdout
** Build failed with error **
JSON operation failed: $missing field packageUri
at line 1 column 9839Text:
{"configVersion":2,"packages":[{"name":"async","rootUri":"file:///home/bus710/flutter/.pub-cache/hosted/pub.dartlang.org/async-2.8.2","packageUri":"lib/","languageVersion":"2.12"},{"name":"boolean_selector","rootUri":"file:///home/bus710/flutter/.pub-cache/hosted/pub.dartlang.org/boolean_selector-2.1.0","packageUri":"lib/","languageVersion":"2.12"},{"name":"characters","rootUri":"file:///home/bus710/flutter/.pub-cache/hosted/pub.dartlang.org/characters-1.1.0","packageUri":"lib/","languageVersion":"2.12"},{"name":"charcode","rootUri":"file:///home/bus710/flutter/.pub-cache/hosted/pub.dartlang.org/charcode-1.3.1","packageUri":"lib/","languageVersion":"2.12"},{"name":"clock","rootUri":"file:///home/bus710/flutter/.pub-cache/hosted/pub.dartlang.org/clock-1.1.0","packageUri":"lib/","languageVersion":"2.12"},{"name":"collection","rootUri":"file:///home/bus710/flutter/.pub-cache/hosted/pub.dartlang.org/collection-1.15.0","packageUri":"lib/","languageVersion":"2.12"},{"name":"cupertino_icons","rootUri":"file:///home/bus710/flutter/.pub-cache/hosted/pub.dartlang.org/cupertino_icons-1.0.3","packageUri":"lib/","languageVersion":"2.12"},{"name":"fake_async","rootUri":"file:///home/bus710/flutter/.pub-cache/hosted/pub.dartlang.org/fake_async-1.2.0","packageUri":"lib/","languageVersion":"2.12"},{"name":"ffi","rootUri":"file:///home/bus710/flutter/.pub-cache/hosted/pub.dartlang.org/ffi-1.1.2","packageUri":"lib/","languageVersion":"2.12"},{"name":"file","rootUri":"file:///home/bus710/flutter/.pub-cache/hosted/pub.dartlang.org/file-6.1.1","packageUri":"lib/","languageVersion":"2.12"},{"name":"flutter","rootUri":"file:///home/bus710/flutter/packages/flutter","packageUri":"lib/","languageVersion":"2.12"},{"name":"flutter_test","rootUri":"file:///home/bus710/flutter/packages/flutter_test","packageUri":"lib/","languageVersion":"2.12"},{"name":"flutter_web_plugins","rootUri":"file:///home/bus710/flutter/packages/flutter_web_plugins","packageUri":"lib/","languageVersion":"2.12"},{"name":"http","rootUri":"file:///home/bus710/flutter/.pub-cache/hosted/pub.dartlang.org/http-0.13.3","packageUri":"lib/","languageVersion":"2.12"},{"name":"http_parser","rootUri":"file:///home/bus710/flutter/.pub-cache/hosted/pub.dartlang.org/http_parser-4.0.0","packageUri":"lib/","languageVersion":"2.12"},{"name":"js","rootUri":"file:///home/bus710/flutter/.pub-cache/hosted/pub.dartlang.org/js-0.6.3","packageUri":"lib/","languageVersion":"2.12"},{"name":"matcher","rootUri":"file:///home/bus710/flutter/.pub-cache/hosted/pub.dartlang.org/matcher-0.12.11","packageUri":"lib/","languageVersion":"2.12"},{"name":"meta","rootUri":"file:///home/bus710/flutter/.pub-cache/hosted/pub.dartlang.org/meta-1.7.0","packageUri":"lib/","languageVersion":"2.12"},{"name":"nativeshell","rootUri":"file:///home/bus710/flutter/.pub-cache/hosted/pub.dartlang.org/nativeshell-0.1.10","packageUri":"lib/","languageVersion":"2.13"},{"name":"package_info_plus","rootUri":"file:///home/bus710/flutter/.pub-cache/hosted/pub.dartlang.org/package_info_plus-1.0.1","packageUri":"lib/","languageVersion":"2.12"},{"name":"package_info_plus_linux","rootUri":"file:///home/bus710/flutter/.pub-cache/hosted/pub.dartlang.org/package_info_plus_linux-1.0.2","packageUri":"lib/","languageVersion":"2.12"},{"name":"package_info_plus_macos","rootUri":"file:///home/bus710/flutter/.pub-cache/hosted/pub.dartlang.org/package_info_plus_macos-1.1.1","packageUri":"lib/","languageVersion":"2.12"},{"name":"package_info_plus_platform_interface","rootUri":"file:///home/bus710/flutter/.pub-cache/hosted/pub.dartlang.org/package_info_plus_platform_interface-1.0.1","packageUri":"lib/","languageVersion":"2.12"},{"name":"package_info_plus_web","rootUri":"file:///home/bus710/flutter/.pub-cache/hosted/pub.dartlang.org/package_info_plus_web-1.0.1","packageUri":"lib/","languageVersion":"2.12"},{"name":"package_info_plus_windows","rootUri":"file:///home/bus710/flutter/.pub-cache/hosted/pub.dartlang.org/package_info_plus_windows-1.0.1","packageUri":"lib/","languageVersion":"2.12"},{"name":"path","rootUri":"file:///home/bus710/flutter/.pub-cache/hosted/pub.dartlang.org/path-1.8.0","packageUri":"lib/","languageVersion":"2.12"},{"name":"path_provider","rootUri":"file:///home/bus710/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider-2.0.2","packageUri":"lib/","languageVersion":"2.12"},{"name":"path_provider_linux","rootUri":"file:///home/bus710/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider_linux-2.0.0","packageUri":"lib/","languageVersion":"2.12"},{"name":"path_provider_macos","rootUri":"file:///home/bus710/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider_macos-2.0.0","packageUri":"lib/","languageVersion":"2.12"},{"name":"path_provider_platform_interface","rootUri":"file:///home/bus710/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider_platform_interface-2.0.1","packageUri":"lib/","languageVersion":"2.12"},{"name":"path_provider_windows","rootUri":"file:///home/bus710/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider_windows-2.0.1","packageUri":"lib/","languageVersion":"2.12"},{"name":"pedantic","rootUri":"file:///home/bus710/flutter/.pub-cache/hosted/pub.dartlang.org/pedantic-1.11.0","packageUri":"lib/","languageVersion":"2.12"},{"name":"platform","rootUri":"file:///home/bus710/flutter/.pub-cache/hosted/pub.dartlang.org/platform-3.0.0","packageUri":"lib/","languageVersion":"2.12"},{"name":"plugin_platform_interface","rootUri":"file:///home/bus710/flutter/.pub-cache/hosted/pub.dartlang.org/plugin_platform_interface-2.0.0","packageUri":"lib/","languageVersion":"2.12"},{"name":"process","rootUri":"file:///home/bus710/flutter/.pub-cache/hosted/pub.dartlang.org/process-4.2.1","packageUri":"lib/","languageVersion":"2.12"},{"name":"shared_preferences","rootUri":"file:///home/bus710/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences-2.0.6","packageUri":"lib/","languageVersion":"2.12"},{"name":"shared_preferences_linux","rootUri":"file:///home/bus710/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences_linux-2.0.0","packageUri":"lib/","languageVersion":"2.12"},{"name":"shared_preferences_macos","rootUri":"file:///home/bus710/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences_macos-2.0.0","packageUri":"lib/","languageVersion":"2.12"},{"name":"shared_preferences_platform_interface","rootUri":"file:///home/bus710/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences_platform_interface-2.0.0","packageUri":"lib/","languageVersion":"2.12"},{"name":"shared_preferences_web","rootUri":"file:///home/bus710/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences_web-2.0.0","packageUri":"lib/","languageVersion":"2.12"},{"name":"shared_preferences_windows","rootUri":"file:///home/bus710/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences_windows-2.0.0","packageUri":"lib/","languageVersion":"2.12"},{"name":"sky_engine","rootUri":"file:///home/bus710/flutter/bin/cache/pkg/sky_engine","packageUri":"lib/","languageVersion":"2.12"},{"name":"source_span","rootUri":"file:///home/bus710/flutter/.pub-cache/hosted/pub.dartlang.org/source_span-1.8.1","packageUri":"lib/","languageVersion":"2.12"},{"name":"stack_trace","rootUri":"file:///home/bus710/flutter/.pub-cache/hosted/pub.dartlang.org/stack_trace-1.10.0","packageUri":"lib/","languageVersion":"2.12"},{"name":"stream_channel","rootUri":"file:///home/bus710/flutter/.pub-cache/hosted/pub.dartlang.org/stream_channel-2.1.0","packageUri":"lib/","languageVersion":"2.12"},{"name":"string_scanner","rootUri":"file:///home/bus710/flutter/.pub-cache/hosted/pub.dartlang.org/string_scanner-1.1.0","packageUri":"lib/","languageVersion":"2.12"},{"name":"term_glyph","rootUri":"file:///home/bus710/flutter/.pub-cache/hosted/pub.dartlang.org/term_glyph-1.2.0","packageUri":"lib/","languageVersion":"2.12"},{"name":"test_api","rootUri":"file:///home/bus710/flutter/.pub-cache/hosted/pub.dartlang.org/test_api-0.4.3","packageUri":"lib/","languageVersion":"2.12"},{"name":"typed_data","rootUri":"file:///home/bus710/flutter/.pub-cache/hosted/pub.dartlang.org/typed_data-1.3.0","packageUri":"lib/","languageVersion":"2.12"},{"name":"url_launcher","rootUri":"file:///home/bus710/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher-6.0.6","packageUri":"lib/","languageVersion":"2.12"},{"name":"url_launcher_linux","rootUri":"file:///home/bus710/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher_linux-2.0.0","packageUri":"lib/","languageVersion":"2.12"},{"name":"url_launcher_macos","rootUri":"file:///home/bus710/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher_macos-2.0.0","packageUri":"lib/","languageVersion":"2.12"},{"name":"url_launcher_platform_interface","rootUri":"file:///home/bus710/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher_platform_interface-2.0.3","packageUri":"lib/","languageVersion":"2.12"},{"name":"url_launcher_web","rootUri":"file:///home/bus710/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher_web-2.0.1","packageUri":"lib/","languageVersion":"2.12"},{"name":"url_launcher_windows","rootUri":"file:///home/bus710/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher_windows-2.0.0","packageUri":"lib/","languageVersion":"2.12"},{"name":"vector_math","rootUri":"file:///home/bus710/flutter/.pub-cache/hosted/pub.dartlang.org/vector_math-2.1.0","packageUri":"lib/","languageVersion":"2.12"},{"name":"win32","rootUri":"file:///home/bus710/flutter/.pub-cache/hosted/pub.dartlang.org/win32-2.1.3","packageUri":"lib/","languageVersion":"2.13"},{"name":"xdg_directories","rootUri":"file:///home/bus710/flutter/.pub-cache/hosted/pub.dartlang.org/xdg_directories-0.2.0","packageUri":"lib/","languageVersion":"2.12"},{"name":"nativeshell_examples","rootUri":"../","packageUri":"lib/","languageVersion":"2.12"},{"name":"flutter_gen","rootUri":"flutter_gen","languageVersion":"2.12"}],"generated":"2021-10-15T16:29:46.750823Z","generator":"pub","generatorVersion":"2.15.0-82.2.beta"}
--- stderr
thread 'main' panicked at 'explicit panic', build.rs:26:9
stack backtrace:
0: std::panicking::begin_panic
at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/std/src/panicking.rs:541:12
1: build_script_build::main
at ./build.rs:26:9
2: core::ops::function::FnOnce::call_once
at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/core/src/ops/function.rs:227:5
note: Some details are omitted, run with RUST_BACKTRACE=full
for a verbose backtrace.
warning: build failed, waiting for other jobs to finish...
error: build failed
The error just says "build.rs" panicked. I had no clue because my setup seems fine to me.
Then I wanted to check if the example would be built without NativeShell. So I tried "flutter run" to build desktop/web app. For some reason, I couldn't see anything on the screen. At that moment I thought the flutter example might have some issue in the first place, but there is no issue in the issues. Then I just tried "cargo run" again.....
So my shallow conclusion is that, there were not sufficient flutter packages downloaded/installed when I ran "cargo run" earlier, but the "flutter run" did it for me. Then the second trial was successful.
... I know this is a silly story, but I just hope people don't give up because of this.