When creating a flutter app with Visual Studio Code and trying to upload it to the Google Play Store via the Google Play Store Console, I received the following error:
"The use of "com.example" is subject to restrictions. Please use a different package name"
This relates to the default name used that includes the example part. There are many guides online on the relevance of the package name, naming convention, and how to update the name in Android Studio.
I was completely lost in how to update it in Android Visual Studio Code…
2
Answers
Some online guides propose to only change the two occurrences of "com.example" in the build.gradle, which is located in apppath/android/app/
from
to
However: While, after 1) saving, 2) flutter clean, 3) flutter build appbundle, the new version might actually be accepted by the Play Store, there might be issues with starting the app, since the package name has not been updated across all occurrences in the code. Under Visual Studio Code, I was not able to use refactor features, that seem to be able to help out with fully replacing these in Android Studio.
However, you can replace all occurrence via edit -> find in files -> with input "com.example". Once replacing "example" by "newname" for all occurrences, the app was able to both function correctly and be uploaded to Play Store.
Hope this helps some people struggling with the same problem :)
In this cause you can change your configuration in your build.gradle in app level.
When you went to your build.gradle in app level you can see
applicationId
in deaultConfig section like bellow code.so when we want to upload our app into playstore we should change
applicationId
like bellow.because it should be unique. you can findout more details refer flutter documentation using this link. look at updated code,
and rebuild your project again now you can avoid this issue.