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

Cannot run the app to Pi 4B #22

Closed
EnziinSystem opened this issue Apr 16, 2024 · 16 comments
Closed

Cannot run the app to Pi 4B #22

EnziinSystem opened this issue Apr 16, 2024 · 16 comments
Assignees
Labels
bug Something isn't working

Comments

@EnziinSystem
Copy link

I can list devices

snapp_cli devices list

✓  Searching for custom devices completed!

List of custom devices in "C:\Users\enzii\AppData\Roaming\.flutter_custom_devices.json":
  id: pi-5, label: Raspberry Pi 5, enabled: true
  id: pi-4b, label: Raspberry Pi 4 Model B, enabled: true

However, it cannot run an application to Pi 4 on debug mode

 flutter run -d pi-4b
Launching lib\main.dart on Raspberry Pi 4 Model B in debug mode...
Error: No pubspec.yaml file found.
This command should be run from the root of your Flutter project.
cp: target '/tmp/flutter_application_1/build/flutter_assets' is not a directory
cp: target '/tmp/flutter_application_1/build/linux/arm64/debug/bundle/data/flutter_assets' is not a directory
cp: cannot create regular file '/tmp/flutter_application_1/build/linux/arm64/debug/bundle/data': No such file or directory
bash: line 1: /tmp/flutter_application_1/build/linux/arm64/debug/bundle/flutter_application_1: No such file or directory
@payam-zahedi
Copy link
Member

@EnziinSystem Thanks for opening this issue

I can see this line in the error text
Error: No pubspec.yaml file found.

Is the pubspec.yaml file missing from the root of your project?

@EnziinSystem
Copy link
Author

EnziinSystem commented Apr 18, 2024

pubspec.yaml

I use Windows for development and deploy to a Pi-4 or Pi-5.

So my project on Windows works on Windows itself and Android, iOS and of course, it has a pubspec.yaml file in the root directory.

This error only appears on Pi-4B and not on other platforms.

It seems to be related to the process of copying files from Windows to Pi-4

Screenshot 2024-04-18 121134

@payam-zahedi
Copy link
Member

Yes you are right that's the problem

Can you tell me which version of the snapp_cli do you use?

@payam-zahedi
Copy link
Member

Also, Can you check that you can use passwordless ssh connection?

I mean, you should be able to connect to your raspberry with this simple command without entering the password

ssh username@ipAddress

example

ssh [email protected]

@EnziinSystem
Copy link
Author

EnziinSystem commented Apr 18, 2024

Also, Can you check that you can use passwordless ssh connection?

I mean, you should be able to connect to your raspberry with this simple command without entering the password

ssh username@ipAddress

example

ssh [email protected]

I still connect SSH via authorized_keys without a password.

snapp_cli -v       
Verbose mode enabled

Snapp_cli Current version: 0.5.0
Snapp_cli Latest version: 0.5.0
Snapp_cli needs update: false

On the Pi-4B I installed snap_installer and tested without any errors.

More importantly, I was able to run an application developed on Windows, connected to Pi4B with full hot-reload.

However, later times it cannot be done anymore.

Or in short, I did it once.

@payam-zahedi payam-zahedi self-assigned this Apr 18, 2024
@payam-zahedi payam-zahedi added the bug Something isn't working label Apr 18, 2024
@payam-zahedi
Copy link
Member

This is very strange.

If it's possible for you, I would suggest to set time and try to debug it together.
It's also important for us to find the bugs in snapp cli.

@EnziinSystem
Copy link
Author

This is very strange.

If it's possible for you, I would suggest to set time and try to debug it together. It's also important for us to find the bugs in snapp cli.

I agree with your suggestion, you can even use Teamviewer to access my computer directly.
This is a meaningful project in the embedded field.
I will arrange a time next week.

@RootKid87
Copy link

RootKid87 commented Apr 23, 2024

Hi any news related to this issue?

after execute
flutter clean and flutter pub get the application start running on rpi 4b.

Unfortunately I have the following errors.

Building Linux application...
cp: -r not specified; omitting directory '/tmp/counter_app/snapp_embedded/flutter_assets/fonts'
cp: -r not specified; omitting directory '/tmp/counter_app/snapp_embedded/flutter_assets/packages'
cp: -r not specified; omitting directory '/tmp/counter_app/snapp_embedded/flutter_assets/shaders'
cp: -r not specified; omitting directory '/tmp/counter_app/snapp_embedded/flutter_assets/fonts'
cp: -r not specified; omitting directory '/tmp/counter_app/snapp_embedded/flutter_assets/packages'
cp: -r not specified; omitting directory '/tmp/counter_app/snapp_embedded/flutter_assets/shaders'
[ERROR:flutter/shell/common/shell.cc(117)] Dart Error: Can't load Kernel binary: Invalid SDK hash.
[ERROR:flutter/runtime/dart_isolate.cc(144)] Could not prepare isolate.
[ERROR:flutter/runtime/runtime_controller.cc(462)] Could not create root isolate.
[ERROR:flutter/shell/common/shell.cc(669)] Could not launch engine with configuration.

kind regards

@payam-zahedi
Copy link
Member

Hi any news related to this issue?

after execute flutter clean and flutter pub get the application start running on rpi 4b.

Unfortunately I have the following errors.

Building Linux application... cp: -r not specified; omitting directory '/tmp/counter_app/snapp_embedded/flutter_assets/fonts' cp: -r not specified; omitting directory '/tmp/counter_app/snapp_embedded/flutter_assets/packages' cp: -r not specified; omitting directory '/tmp/counter_app/snapp_embedded/flutter_assets/shaders' cp: -r not specified; omitting directory '/tmp/counter_app/snapp_embedded/flutter_assets/fonts' cp: -r not specified; omitting directory '/tmp/counter_app/snapp_embedded/flutter_assets/packages' cp: -r not specified; omitting directory '/tmp/counter_app/snapp_embedded/flutter_assets/shaders' [ERROR:flutter/shell/common/shell.cc(117)] Dart Error: Can't load Kernel binary: Invalid SDK hash. [ERROR:flutter/runtime/dart_isolate.cc(144)] Could not prepare isolate. [ERROR:flutter/runtime/runtime_controller.cc(462)] Could not create root isolate. [ERROR:flutter/shell/common/shell.cc(669)] Could not launch engine with configuration.

kind regards

I think you issue is related to your flutter SDK version

Make sure that you have the same version of the flutter both on your Host and your remote.

@RootKid87
Copy link

Thanks for quick reply. I will check it 👍🏻

@EnziinSystem
Copy link
Author

EnziinSystem commented Apr 24, 2024

I checked flutter version on both Pi-5 and PC

On Pi-5 (and Pi-4B)

flutter doctor -v
[✓] Flutter (Channel stable, 3.19.6, on Debian GNU/Linux 12 (bookworm) 6.6.20+rpt-rpi-2712, locale en_GB.UTF-8)
    • Flutter version 3.19.6 on channel stable at /home/developer/sdk/flutter
    • Upstream repository https://github.com/flutter/flutter
    • Framework revision 54e66469a9 (6 days ago), 2024-04-17 13:08:03 -0700
    • Engine revision c4cd48e186
    • Dart version 3.3.4
    • DevTools version 2.31.1

On PC

flutter --version       
Flutter 3.19.6 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 54e66469a9 (6 days ago) • 2024-04-17 13:08:03 -0700
Engine • revision c4cd48e186
Tools • Dart 3.3.4 • DevTools 2.31.1

For detail, run snapp_cli in Verbose mode

snapp_cli bootstrap -v
Verbose mode enabled

Snapp_cli Current version: 0.5.0
Snapp_cli Latest version: 0.5.0
Snapp_cli needs update: false



Bootstrap command is a way to setup a device from scratch.
It will add a new device to custom devices, create a ssh connection to the device,
install flutter on the device and finally help you to run your app on the device.

let's start!



✔ Please select the type of device you want to setup. · Express (recommended)

✔ Select your device · Raspberry Pi 5


to setup a new device, we need an IP address and a username.
Please enter the IP-address of the device. (example: 192.168.1.101)

✔ Device IP-address: · 192.168.0.107

Please enter the username used for ssh-ing into the remote device. (example: pi)

✔ Username: · developer                                                                                                                                                


⠇ Testing SSH connection
testPasswordLessSshConnection ExitCode: 0
testPasswordLessSshConnection Stdout: Test SSH Connection
✓  Testing SSH connection completed                                                                                                                                    

We need the exact path of your flutter command line tools on the remote device. We will use this path to run flutter commands on the remote device like "flutter build linux --debug".

⠸ search for flutter path on remote device.
Find Flutter ExitCode: 1
Find Flutter Stdout: /home/developer/sdk/flutter/bin/flutter
✓  search for flutter path completed                                                                                                                                   
Find Flutter output: /home/developer/sdk/flutter/bin/flutter

We found flutter in "/home/developer/sdk/flutter/bin/flutter" in the remote machine.
✔ Do you want to use this path? · yes
⠹ Search for flutter version on remote device.
Find Flutter Version ExitCode: 0
Find Flutter Version Stdout: {
  "frameworkVersion": "3.19.6",
  "channel": "stable",
  "repositoryUrl": "https://github.com/flutter/flutter",
  "frameworkRevision": "54e66469a933b60ddf175f858f82eaeb97e48c8d",
  "frameworkCommitDate": "2024-04-17 13:08:03 -0700",
  "engineRevision": "c4cd48e186460b32d44585ce3c103271ab676355",
  "dartSdkVersion": "3.3.4",
  "devToolsVersion": "2.31.1",
  "flutterVersion": "3.19.6",
  "flutterRoot": "/home/developer/sdk/flutter"
}
✓  Search for flutter version completed                                                                                                                                
Find Flutter Version jsonOutput: {frameworkVersion: 3.19.6, channel: stable, repositoryUrl: https://github.com/flutter/flutter, frameworkRevision: 54e66469a933b60ddf175f858f82eaeb97e48c8d, frameworkCommitDate: 2024-04-17 13:08:03 -0700, engineRevision: c4cd48e186460b32d44585ce3c103271ab676355, dartSdkVersion: 3.3.4, devToolsVersion: 2.31.1, flutterVersion: 3.19.6, flutterRoot: /home/developer/sdk/flutter}
Find Flutter Version jsonOutput[flutterVersion]: 3.19.6
Find Flutter Version output: 3.19.6

remote flutter version: 3.19.6
host flutter version: 3.19.6
✓You have flutter installed on the remote machine with the same version as your host machine.


✓Successfully added custom device to config file at "C:\Users\xx\AppData\Roaming\.flutter_custom_devices.json".

Run an app demo from PC deploy to Pi-5

flutter run -d pi-5
Launching lib\main.dart on Raspberry Pi 5 in debug mode...
Error: No pubspec.yaml file found.
This command should be run from the root of your Flutter project.
cp: target '/tmp/basic/build/flutter_assets': No such file or directory
cp: target '/tmp/basic/build/linux/arm64/debug/bundle/data/flutter_assets': No such file or directory
cp: cannot create regular file '/tmp/basic/build/linux/arm64/debug/bundle/data': No such file or directory
bash: line 1: /tmp/basic/build/linux/arm64/debug/bundle/basic: No such file or directory

List root path project

PS C:\Users\xx\Downloads\flutter\basic\basic> ls


    Directory: C:\Users\xx\Downloads\flutter\basic\basic


Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d-----         4/23/2024   8:39 AM                .dart_tool
d-----         4/23/2024   8:38 AM                .idea
d-----         4/23/2024   9:21 AM                android
d-----         4/24/2024  10:35 AM                build
d-----         4/23/2024   8:38 AM                ios
d-----         4/23/2024   8:38 AM                lib
d-----         4/23/2024   8:38 AM                linux
d-----         4/23/2024   8:38 AM                macos
d-----         4/23/2024   8:38 AM                test
d-----         4/23/2024   8:38 AM                web
d-----         4/23/2024   8:38 AM                windows
-a----         4/23/2024   8:38 AM            734 .gitignore
-a----         4/23/2024   8:39 AM           1706 .metadata
-a----         4/23/2024   8:38 AM           1448 analysis_options.yaml
-a----         4/23/2024   8:38 AM            859 basic.iml
-a----         4/24/2024  10:17 AM           6037 pubspec.lock
-a----         4/23/2024   8:38 AM           3960 pubspec.yaml
-a----         4/23/2024   8:38 AM            564 README.md

The problem is unsolved.

@RootKid87
Copy link

I check the flutter versions on host and pi. On pi it was 3.19.6 and on host 3.19.4. After update to same version no more issues. 👍🏻

@EnziinSystem
Copy link
Author

EnziinSystem commented Apr 24, 2024

Steps that create this problem:

Step 1: Create a new project by VS Code

Step 2: Add window_manager plugin to pubspec.yaml

dependencies:
  flutter:
    sdk: flutter


  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  cupertino_icons: ^1.0.6
  window_manager: ^0.3.8

VS Code automation run flutter pub get plugins

Step 3: Run deploy to Pi-5

flutter run -d pi-5
Launching lib\main.dart on Raspberry Pi 5 in debug mode...
Error: No pubspec.yaml file found.
This command should be run from the root of your Flutter project.
cp: -r not specified; omitting directory '/tmp/smarthome/snapp_embedded/flutter_assets/fonts'
cp: -r not specified; omitting directory '/tmp/smarthome/snapp_embedded/flutter_assets/packages'
cp: -r not specified; omitting directory '/tmp/smarthome/snapp_embedded/flutter_assets/shaders'
cp: target '/tmp/smarthome/build/linux/arm64/debug/bundle/data/flutter_assets': No such file or directory
cp: cannot create regular file '/tmp/smarthome/build/linux/arm64/debug/bundle/data': No such file or directory
bash: line 1: /tmp/smarthome/build/linux/arm64/debug/bundle/smarthome: No such file or directory

However, the application can still compile and run on Windows.

The reason is the window_manager plugin, but I don't have the ability to find out specifically.

Update:

I found that any project that uses standard packages other than the counter basic app when creating a new project causes the above error.

This example uses the Bloc package, a common design pattern, which also causes an error:

name: flutter_counter
description: A new Flutter project.
version: 1.0.0+1
publish_to: none

environment:
  sdk: ">=3.0.0 <4.0.0"

dependencies:
  bloc: ^8.1.0
  flutter:
    sdk: flutter
  flutter_bloc: ^8.1.1

dev_dependencies:
  bloc_test: ^9.1.0
  flutter_test:
    sdk: flutter
  integration_test:
    sdk: flutter
  mocktail: ^1.0.0

flutter:
  uses-material-design: true

@payam-zahedi
Copy link
Member

@EnziinSystem

I could try to test this scenario with macOS for now.

Snapp cli is working perfectly even if you have added some plugins

Example:

import 'package:flutter/material.dart';
import 'package:window_manager/window_manager.dart';

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  // Must add this line.
  await windowManager.ensureInitialized();

  WindowOptions windowOptions = const WindowOptions(
    size: Size(800, 600),
    center: true,
    backgroundColor: Colors.transparent,
    skipTaskbar: false,
    titleBarStyle: TitleBarStyle.hidden,
  );

  windowManager.waitUntilReadyToShow(windowOptions, () async {
    await windowManager.show();
    await windowManager.focus();
  });

  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  int _counter = 0;

  void _incrementCounter() {
    setState(() {
      _counter++;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            const Text(
              'You have pushed the button this many times:',
            ),
            Text(
              '$_counter',
              style: Theme.of(context).textTheme.headlineMedium,
            ),
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: _incrementCounter,
        tooltip: 'Increment',
        child: const Icon(Icons.add),
      ), // This trailing comma makes auto-formatting nicer for build methods.
    );
  }
}

@payam-zahedi
Copy link
Member

@EnziinSystem

I will also try to reproduce this in windows and linux.

But probably your problem is related to file/folder access permission.

Can you try to reproduce this with root user?

@payam-zahedi
Copy link
Member

I will close this issue for now

Feel free to reopen it if you had the same problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants