JS1
JS1

Reputation: 767

How to specify project entrypoint to gradle build

In my flutter project when I run either :

./gradlew build

or

gradle build

I get this type of error :

.dart_tool/flutter_build/generated_main.dart:11:8: Error: Error when reading 'lib/main.dart': Le fichier sp├®cifi├® est introuvable.

This is because my main.dart is located in "lib/src/main" instead of "lib" , and it needs to stays that way.

When I run my build with flutter I use an option to specify the main location :

flutter build apk -t "lib/src/main/main.dart"

And it works fine.

Is there such option for./gradlew build or gradle build ?

Thanks.

Upvotes: 1

Views: 1154

Answers (2)

Ernesto
Ernesto

Reputation: 103

Here's the answer...

./gradlew build -Ptarget=lib/entry_point_name.dart

The -P indicates gradle that what follows is a project parameter, in this case the parameter's name is 'target'. This parameter is used to override the default main.dart entry point.

Upvotes: 2

Basel Abuhadrous
Basel Abuhadrous

Reputation: 1670

If you are using android studio then follow these steps:

1: Go to edit configurationsenter image description here

2: Change the entry point enter image description here

Thats it.

Upvotes: 0

Related Questions