01-edu / public

📚 @01-edu's Public Repository
http://public.01-edu.org/
202 stars 429 forks source link

[BUG] Mobile-Dev piscine - Package task: can't be run on android #2485

Closed sailordi closed 3 months ago

sailordi commented 4 months ago

When you try to run the app on a android device you get the error

FAILURE: Build failed with an exception.

Project: https://github.com/01-edu/public/tree/master/subjects/mobile-dev/package

blueskiy01 commented 4 months ago

Can confirm, was victim of this and took 2 days to figure out it doesn't work with android device but works with desktop ios.

Screenshot 2024-03-07 at 9 59 00
nprimo commented 4 months ago

Hi @sailordi and @blueskiy01 could you please add more details? The subject ask to develop a library using a Flutter package that supports iOS, Android and MacOS.

sailordi commented 4 months ago

@nprimo When you create the project package the module name automatically becomes package. This means a package named package is created for Android. In Kotlin / Java the word package is a keyword which can cause the app to not run on Android. This means we have to change the module name when creating the project to get it to run on Android which is not something that we should have to do to get a project to work.

nprimo commented 4 months ago

Hi @sailordi, thank you for the additional information.

In the subject it is stated:

In the end you should be able to import it like:

import 'package:note/note.dart';

I assume the package name should be node and not package. (I am assuming that in the above comment module is used as an equivalent of package). Was the error occurring when the name of the package was package and the import statement was as follows?

import 'package:package/note.dart';
sailordi commented 4 months ago

@nprimo The problem is not with the package note it is with application package. The application name it self causes a conflict when you try to run it on android.

nprimo commented 4 months ago

@sailordi I am still confused about the cause of the issue. The subject ask to create a package (not an application) name note (so far no issues should arise due to "naming conflicts"). The subject also refers to a previously made application (secure-note) that could use the classes implemented in this package. Therefore, where is the package application coming from?

sailordi commented 4 months ago

@nprimo Ok so the issue is that we did not have secure-note during the piscine (see image below). This made us create the app as well as the package at the same tile leading me to call the app the same as the task (package). On the package project there is no link to the secure-note git repo meaning we would have to go serching for it if we wanted to see it.

Screenshot 2024-03-22 at 11 01 48
nprimo commented 3 months ago

Hi @sailordi, thank you for the clarification: now everything is clear :)

I will update the subject to have a direct link to the referred project. Besides that, the subject looks good to me: it is not required to create an app with the exercise name and, overall, it is always a good practice to use key words to name your apps/libraries/packages... If there are other things that could improve feel free to comment here.