very_good_cli
very_good_cli copied to clipboard
Application ID does not appear in Android files (AndroidManifest and MainActivity)
Description
When we create a project, the argument --argument-id is not used in several Android config files.
Steps To Reproduce
-
Create a Flutter project with the command :
very_good create flutter_app foo --application-id com.foo.app -
Open the files :
foo/android/app/src/main/AndroidManifest.xmlfoo/android/app/src/debug/AndroidManifest.xmlfoo/android/app/src/profile/AndroidManifest.xmlfoo/android/app/src/main/kotlin/com/foo/MainActivity.kt
-
Check the package names in those files
-
Start again with the command :
very_good create flutter_app foo --org com.foo --application-id com.foo.app
Expected Behavior
The package name must be : com.foo.app
But it is instead : com.example.verygoodcore.foo or com.foo.foo
Screenshots
Hi @icodeyou thanks for opening an issue 💙 !
I've been able to reproduce this in very_good_cli 0.21.0. When creating using very_good create flutter_app foo --application-id com.foo.app my manifest package is com.foo.foo. Whereas the default config applicationId is simply "com.foo.app" (at build.gradel).
@TofferJ are you able to reproduce and verify the need of this change? Currently the manifest package name is intended to be {{org_name.dotCase()}}.{{project_name.snakeCase()}},
The application ID should not be in the AndroidManifest or the MainActivity class. It resides in the build.gradle file, as @alestiago mentioned above. It is only used to identify your application in the Play Store.
The package name in the AndroidManifest is what dictates the directory structure of your code. It is what you should see in package definition in e.g. the MainActivity class.
It is perfectly fine for the two to be different. The package name can be changed at any time, but the application ID can not be changed once your app has been published.
You could argue that it might be expected, or nicer, to have them both be the same after initializing the project. Personally, I think that having different default values helps people understand that they are not one and the same. I would recommend keeping things as is for now, but continue to monitor any feedback related to their default values.
I see. It is good to know that it has no impact on the way it is identified by the Play Store.
I still prefer to have a package name identical to the application ID, because I believe it is what is done by default when you create an native Android project. I think it would be great to keep things as closely as the way it is for most projects.
By the way, when we create a project with flutter create the application ID and the package are identical.
Is there a good reason to change this behavior ?
⚠️ ⚠️ ⚠️ Hello, I tried for the first time to run the app on my Android device, and now it seems that the problem is critical. ⚠️ ⚠️ ⚠️
Whenever I create an app using application-id :
very_good create flutter_app foo --application-id com.foo.app
When I run this app on my Android, the code will not compile !!!!! I have the following error :
/Users/mb/dev/temp/FLUTTER/TEST/youniqueid/android/app/src/debug/AndroidManifest.xml Error:
Overlay manifest:package attribute declared at AndroidManifest.xml:2:5-50 value=(com.example.verygoodcore.youniqueid)
does not match the module's namespace (com.youniqueid.app).
Suggestion: remove the overlay declaration at AndroidManifest.xml.
If you want to customize the applicationId for a buildType or productFlavor, consider setting applicationIdSuffix or using the Variant API.
For more information, see https://developer.android.com/studio/build/build-variants
FAILURE: Build failed with an exception.
PS : I updated flutter and very_good to the last version. very_good version : 0.22.0 Flutter version : 3.22.2
Thanks @icodeyou for providing further information! I was able to reproduce the warning using Very Good CLI 0.22.1.
- Created the project using:
very_good create flutter_app foo --application-id com.foo.app
- Running the application on an Android device:
/Users/alestiago/Desktop/temp/foo/android/app/src/debug/AndroidManifest.xml Error:
Overlay manifest:package attribute declared at AndroidManifest.xml:2:5-26 value=(com.foo.foo)
does not match the module's namespace (com.foo.app).
Suggestion: remove the overlay declaration at AndroidManifest.xml.
If you want to customize the applicationId for a buildType or productFlavor, consider setting applicationIdSuffix or using the Variant API.
For more information, see https://developer.android.com/studio/build/build-variants
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:processDevelopmentDebugMainManifest'.
> Manifest merger failed : Overlay manifest:package attribute declared at AndroidManifest.xml:2:5-26 value=(com.foo.foo)
does not match the module's namespace (com.foo.app).
Suggestion: remove the overlay declaration at AndroidManifest.xml.
If you want to customize the applicationId for a buildType or productFlavor, consider setting applicationIdSuffix or using the Variant API.
For more information, see https://developer.android.com/studio/build/build-variants
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 9s
Running Gradle task 'assembleDebug'... 10.4s
Error: Gradle task assembleDebug failed with exit code 1
I believe this comes from a change in the Android Gradle Plugin, from the documentation:
In the Gradle-based build system, starting with AGP 7.3, don't set the package value in the source manifest file directly. For more information, see Set the application ID.
Should be solved with https://github.com/VeryGoodOpenSource/very_good_templates/pull/148, we're pending to do a release so the fix is available.
Very Good Cli 0.22.2 has been released, it should have a fix for this issue.
If the issue persists don't hesitate on letting us now by re-opening the issue! 🙌 💙