Back

[SOLVED] dart & flutter - cloud function execution error from client and server

  • 1
  • Functions
dammy
20 Oct, 2023, 18:10
TypeScript
src/server.dart:115:25: Error: Method not found: 'main'.
              user_code.main(context)
                        ^^^^
src/server.dart:125:38: Error: Method not found: 'main'.
            output = await user_code.main(context);
                                     ^^^^
Error: AOT compilation failed
Generating AOT kernel dill failed!```


Am unable to detect what the error is
Kindly assist if you can
TL;DR
User is experiencing an error while trying to compile a Dart and Flutter project. They are receiving a "Method not found: 'main'" error. They have provided their code and are seeking assistance. Other users suggest checking the function signature, starting from a starter template, and updating the Appwrite CLI version. It is recommended to update the CLI to a higher version and see if that resolves the issue.
dammy
20 Oct, 2023, 18:10

dart - function build error

dammy
20 Oct, 2023, 18:18

dart - function deployment error

VincentGe
20 Oct, 2023, 18:45

Your function signiture is wrong with you function

VincentGe
20 Oct, 2023, 18:45

Can I see your code? Did you start from a starter template?

VincentGe
20 Oct, 2023, 18:45

It's trying to run the main function of your Appwrite function, but isn't finding the main function

dammy
20 Oct, 2023, 19:40

I used the starter template @VincentGe

dammy
20 Oct, 2023, 19:46
TypeScript
  final client = Client();

  // Uncomment the services you need, delete the ones you don't
  // final account = Account(client);
  // final avatars = Avatars(client);
  // final database = Databases(client);
  // final functions = Functions(client);
  // final health = Health(client);
  // final locale = Locale(client);
  // final storage = Storage(client);
  // final teams = Teams(client);
  // final users = Users(client);

  client
      .setEndpoint("https://cloud.appwrite.io/v1")
      .setProject(projectId)
      .setKey("API_KEY")
      .setSelfSigned(status: true);
  emptier();
  setter();
  // api from env var
  apiToken = (req.variables['DAMMY_GONGOZ_API']);
  // decode user request
  userRequest = await jsonDecode(req.payload);

  // decide which service
  superResponse = await whichServiceExec();
  {
    res.json({
      'Status': superResponse,
    });
  }
}```
VincentGe
20 Oct, 2023, 19:48

👀 where did u get this?

VincentGe
20 Oct, 2023, 19:48

this is very very old

dammy
20 Oct, 2023, 19:49

sighs

And the function was created today and autogenerated by appwrite cli

VincentGe
20 Oct, 2023, 19:49

ahhh yes

VincentGe
20 Oct, 2023, 19:49

the CLI

VincentGe
20 Oct, 2023, 19:49

can u do appwrite -v ?

VincentGe
20 Oct, 2023, 19:49

what version is ur cli

VincentGe
20 Oct, 2023, 19:49

maybe we missed something 🙃

dammy
20 Oct, 2023, 19:49

2.0.2

VincentGe
20 Oct, 2023, 19:49

!

dammy
20 Oct, 2023, 19:50

sighs

VincentGe
20 Oct, 2023, 19:50

we're on like

VincentGe
20 Oct, 2023, 19:50
VincentGe
20 Oct, 2023, 19:50

4.1

VincentGe
20 Oct, 2023, 19:50

😅

VincentGe
20 Oct, 2023, 19:50

try updating the CLI

VincentGe
20 Oct, 2023, 19:50

lemme know how that goes

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more